A guide to understanding the distinction between the event loop in browser and Node

Image for post
Image for post
Background Image Courtesy (https://subwallpaper.com/google-chrome-wallpapers-free/ and https://hipwallpaper.com/nodejs-wallpapers/)

Event Loop is a confusing enough topic to newcomers and is not often 100% understood. What makes this even confusing is, there are two buzzwords called “NodeJS Event Loop” and “JavaScript Event Loop” where the latter speaks about the event loop in the browser. This distinction leads to questions such as:

  • Are these two the same, similar in behaviour, or different completely?
  • And if different, what are the differences?
  • If they are the same, why do we have disambiguation of “NodeJS event loop” and “JavaScript Event Loop” in the first place?

In short, Yes, they are similar in certain ways. And also, Yes, they are also different in certain implementation aspects. Therefore, In this article, I’m going to discuss this disambiguation using a couple of examples to clarify some of the burning questions you may have regarding the topic. …

Image for post
Image for post
Background Image Courtesy: https://wallpapercave.com/mythology-wallpapers

NodeJS was born in 2009 and it has gained massive popularity throughout the years because of one reason. It’s just JavaScript! Well, it’s a JavaScript runtime designed to write server-side applications, but the statement that “It’s just JavaScript” is not 100% true.

JavaScript is single-threaded, and it was not designed to run on the server-side where scalability was a critical requirement. …

Image for post
Image for post
Background Image Courtesy: https://www.goodfon.com/wallpaper/world-pc-technology-satellite.html

We all need to embrace the bitter fact that we all, as developers, hated writing unit tests at some point in our career. While some of us still keep hating writing tests (which I don’t blame for), I kind of developed a weird interest in writing unit tests after working with a number of JavaScript (mainly Node.js) projects over the time. And many times, I have seen people arguing about the acceptable unit test coverage both in meetings as well as online developer forums.

After observing all those dramas, and after having terrible experiences myself throughout the years, I thought I should very briefly write down my two cents on writing unit tests with proper coverage. While I jot these down based on my experience in writing unit tests for Node.js applications, I strongly believe that these facts are universal for any type of application written in any programming language. And, I’m pretty sure you might have more experience than me regarding this topic, so feel free to let me know your opinions about this topic which certainly would help me, as well as the other readers. …


Deepal Jayasekara

Baking Code with #Node 👨‍🍳

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store