skip to Main Content

What can be done to improve the situation?

Promise.resolve(1) .then(x => console.log(1)) .catch(x => console.log(2)) .then(x => console.log(3)) Promise.reject(2) .then(x => console.log(4)) .catch(x => console.log(6)) .then(x => console.log(7)) result is "1 6 3 7", but if i add another then() before catch with console.log(6) result will be 1…

VIEW QUESTION

Why does event handler code execute before the synchronous code has been run? – Javascript

I have a question regarding the order of operations in the below code snippet, const EventEmitter = require("events").EventEmitter; const messenger = new EventEmitter(); process.nextTick(() => { console.log("Next Tick"); }); messenger.on("message", (msg) => { console.log("Message: ", msg); }); messenger.emit("message", "Hello"); console.log("The…

VIEW QUESTION
Back To Top
Search