This content originally appeared on DEV Community and was authored by Nitin Sahu
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
This content originally appeared on DEV Community and was authored by Nitin Sahu
Nitin Sahu | Sciencx (2022-02-01T16:12:05+00:00) Queues in Node js. Retrieved from https://www.scien.cx/2022/02/01/queues-in-node-js/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.