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
1 days 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
10 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
17 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
19 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
22 days ago
I think the answer is B) 02431 because the setTimeout with 0ms delay will be executed last.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77