Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Exam Javascript Developer I Topic 5 Question 68 Discussion

Actual exam question for Salesforce's Javascript Developer I exam
Question #: 68
Topic #: 5
[All Javascript Developer I Questions]

Refer to code below:

console.log(0);

setTimeout(() => (

console.log(1);

});

console.log(2);

setTimeout(() => {

console.log(3);

), 0);

console.log(4);

In which sequence will the numbers be logged?

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

Callie
9 hours ago
Haha, this one's a real brain-teaser! I'm gonna go with C) 02413 just to be different. Who knows, maybe the exam folks are trying to catch us out with a trick question.
upvoted 0 times
...
Queenie
9 days ago
Hmm, let's see... If I remember my JavaScript fundamentals, the console.log's will execute in the order they're written, and the setTimeout's will get added to the task queue. So the answer has to be B) 02431. I hope I'm right!
upvoted 0 times
...
Doyle
14 days ago
Hmm, that's an interesting point. I see your rationale. Let's wait for others to share their opinions.
upvoted 0 times
...
Beth
16 days ago
Ah, the classic event loop conundrum! I'm pretty sure the correct answer is B) 02431. Those setTimeout's can be tricky, but I think I've got the hang of it now.
upvoted 0 times
...
Cathrine
18 days ago
I disagree, I believe the answer is C) 02413 because the setTimeout with 0ms delay will be executed first.
upvoted 0 times
...
Doyle
21 days ago
I think the answer is B) 02431 because the setTimeout with 0ms delay will be executed last.
upvoted 0 times
...

Save Cancel