[JS] Understand Javascript event loop

Ever wonder how a single threaded language like Javascript can support concurrency? Of course, via asynchronous callback you will say. But how exactly does it work? or why setTimeout to zero does not enforce a function to be executed immediately?


setTimeout(function() {
}, 0); 


Philip Roberts had a great presentation, explaining how call stack, task queue and event loop work together. This 30-minute long video (you can also skip the first 10 minutes) can help you understand a lot about Javascript event loop.

You can also find his awesome simulation of Javascript event loop here.

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Node JS Online Training from India . or learn thru Javascript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. ES6 Online Training