VPVishal Pandeyincleanasyncjs.hashnode.dev·May 23, 2025 · 3 min readAsync/await:Absolutely! Let's walk through your code line by line with precise explanations, focusing especially on what happens after each awaitand how microtasks are scheduled and executed. ✅ Code Recap: jsCopyEditconsole.log("script start"); async function ...00
VPVishal Pandeyincleanclosure.hashnode.dev·May 23, 2025 · 3 min readclosures pracitse:Here’s a curated list of 20 closure-related JavaScript questions, progressing from easy to hard, covering fundamental to advanced concepts: Easy (1-7) - Basic Understanding What is a closure? (Definition) Write a function counter() that returns a ...00
VPVishal Pandeyincleanclosure.hashnode.dev·May 23, 2025 · 2 min readClosures:1. First Loop (with differentScope function): for(var i=1;i<=5;i++){ const differentScope = (i)=>{ setTimeout(()=>{ console.log(i) },i*1000); } differentScope(i); } Output: 1 2 3 4 5 (each number printed at 1-...00
VPVishal Pandeyincleanasyncjs.hashnode.dev·May 22, 2025 · 3 min readpractise2:console.log("1"); const promise = new Promise((resolve,reject)=>{ console.log("2"); resolve("3") console.log("4") }) promise.then((res)=>{ console.log("5") console.log(res); console.log("6") }) console.log("7") 🔄 Step-by-...00
VPVishal Pandeyincleanasyncjs.hashnode.dev·May 22, 2025 · 5 min readpractise1:const promise1 = new Promise((resolve, reject) => { setTimeout(() => { resolve("promise1 called"); }, 5000); }); const promise2 = new Promise((resolve, reject) => { setTimeout(() => { resolve("promise2 called"); }, 2000); }); async ...00