angular-interview-questions
angular-interview-questions copied to clipboard
What is the expected order of execution for the following JavaScript code snippet, considering asynchronous operations and the event loop?
trafficstars
What is the expected order of execution for the following JavaScript code snippet, considering asynchronous operations and the event loop?
console.log("1. Initial console.log");
setTimeout(() => { console.log("2. setTimeout callback"); }, 0);
fetch('https://api.example.com/data') .then(response => response.json()) .then(data => console.log("3. Fetch response:", data));
Promise.resolve('Promise resolved') .then(value => console.log("4. Promise resolved:", value));