DEV Community

Payalsasmal
Payalsasmal

Posted on

JS output-based Interview question

I recently encountered an intriguing question I'd like to share with you all. Take a guess at the expected output and share your insights! 😌
Image description

Top comments (7)

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

1 4 6 9 2 5 undefined undefined 8 3?

Not 100% on whether the promise next tick guarantee will make the resolve trigger the first then before or after the 2, but guessing after.

EDIT: nope, the 2 is after the next tick promise so it's:

1 4 6 9 5 undefined undefined 8 2 3

Collapse
 
ceyed profile image
Saeed • Edited

1
9
2
4
6
5
7
8
3

Collapse
 
samsamit profile image
Samu Tiainen

1, 9, 2, 3
You just define the promise and never run it?

Collapse
 
gomigoku profile image
Gouthami

1
4
5
9
5
undefined
undefined
8
2
3

Collapse
 
ratgcode profile image
RaĂșl Tejedor

1
9
4
5
5
5
6
7
7
8
2
3

Collapse
 
payalsasmal profile image
Payalsasmal

No. Thik it once again

Collapse
 
itapas profile image
Tapas

1
4
6
9
5
undefined
undefined
8
2
3