DEV Community

Cover image for Queues in Node js
Nitin Sahu
Nitin Sahu

Posted on

Queues in Node js

Have you been using node js for a while now? Are you aware of how things work internally in node js? the queues in node js? Doesn’t matter if your answer is yes or no, I will let you in on one little secret which will clear all your doubts regarding how node js works asynchronously under the hood.

Let’s test your knowledge on node js. If you understand the queues in node js, you would be able to solve the below question.

console.log("1");
setTimeout(() => console.log("2"),0);
var promise = new Promise(function(resolve, reject) {
resolve();
});
promise.then(function(resolve) {
console.log('3');
})
.then(function(resolve) {
console.log('4');
});
console.log("5");

Like what you read?

Read the full article on readosapien.com

Article link

Top comments (0)