🧠 JavaScript Closure Challenge What will be the output? for (var i = 0; i < 3; i++) { setTimeout(() => { console.log(i); }, 100); } Options: A) 0 1 2 B) 3 3 3 C) 1 2 3 D) 0 0 0 Can you explain why? 👀 #javascript #frontend #codingchallenge
JavaScript Closure Challenge: setTimeout Explanation
More Relevant Posts
-
Javascript concept: == vs === This bug looked harmless… console.log(5 == "5"); // true But in production? It broke logic. console.log(5 === "5"); // false 💡 One habit that saved me: → Always use === #JavaScript #WebDevelopment #Frontend #Coding
To view or add a comment, sign in
-
Think you know JavaScript? Explain this output! 👇 What gets printed to the console? A) undefined, 10, 10, 10 B) ReferenceError, 10, 10, 20 C) undefined, 10, 10, 20 D) undefined, 10, 20, 10 #Technology #JavaScript #SoftwareEngineering #WebDevelopment #ProgrammingRiddles #WebDev #Frontend #ReactJS #CleanCode #ProgrammingTips
To view or add a comment, sign in
-
-
🚀 Day 23 - Poll answer & Explanation 💡 **JavaScript Event Loop Explained (Simple & Clear)** ```javascript console.log('S'); Promise.resolve().then(() => console.log('P1')); setTimeout(() => console.log('T1'), 0); Promise.resolve().then(() => console.log('P2')); setTimeout(() => console.log('T2'), 0); console.log('E'); Output: S E P1 P2 T1 T2 ``` 🔹 **Explanation:** * `S` and `E` run first → synchronous code (call stack) * `P1`, `P2` → microtasks (Promises) → run next * `T1`, `T2` → macrotasks (setTimeout) → run last 👉 Microtasks always execute before macrotasks in the event loop. #JavaScript #ReactJS #WebDevelopment #Coding #FrontendDeveloper #InterviewPrep
To view or add a comment, sign in
-
🧠 JavaScript Async/Await Challenge What will be the output? async function test() { console.log("1"); await Promise.resolve(); console.log("2"); } console.log("3"); test(); console.log("4"); Options: A) 3 1 2 4 B) 3 1 4 2 C) 1 3 4 2 D) 3 4 1 2 What do you think the output will be? 👀 #javascript #frontenddeveloper #webdevelopment #codingchallenge
To view or add a comment, sign in
-
Day 81 / 365 👨💻 Recap of recent React tooling sessions. ⚙️ How @vitejs/plugin-react works ⚡ Role of esbuild and Babel (Fast Refresh) 📦 Rollup for production builds 🔢 Version symbols in package.json 📤 Named vs default exports #365DaysOfCode #React #JavaScript #Frontend
To view or add a comment, sign in
-
JavaScript Core Concepts That Make You Think Twice! 🤯 Before you scroll, predict the output of these 👇 console.log(true + false); console.log(true + true); console.log(false + false); console.log(0 == false); console.log(0 === false); console.log("" == false); console.log("" === false); console.log(" " == false); console.log(NaN == NaN); 🧠 Rules being tested here 1. Type coercion 2. Boolean to Number conversion 3. == vs === 4. Truthy & Falsy values 5. Special behavior of NaN 💡 These questions look simple, but they separate surface-level JS knowledge from real core understanding. 👉 Drop your answers in the comments #JavaScript #WebDevelopment #Frontend #CodingInterview #JSBasics #LearnJavaScript #Developers #TechTalk
To view or add a comment, sign in
-
🧠 JavaScript Async/Await Challenge What will be the output? async function test() { console.log("1"); await Promise.resolve(); console.log("2"); } console.log("3"); test(); console.log("4"); Options: A) 3 1 2 4 B) 3 1 4 2 C) 1 3 4 2 D) 3 4 1 2 #javascript #frontenddeveloper #webdevelopment #codingchallenge
To view or add a comment, sign in
-
Node.js is single-threaded… but not really 👀 Behind the scenes, libuv uses a thread pool to handle async tasks like file system operations, DNS, and crypto. Default thread pool size = 4 Can be tuned using UV_THREADPOOL_SIZE Understanding this changed how I think about performance in Node.js 🚀 #NodeJS #Backend #JavaScript #TechLearning
To view or add a comment, sign in
-
Explored Node.js Internals in today’s class ⚡ Process Start → Main Thread → Run Code → Register Callbacks → Start Event Loop. Event Loop handles: Timers → I/O → setImmediate → Close Callbacks. Thanks to Piyush Garg sir for the great explanation 🙌 Chai Code #NodeJS #JavaScript #Backend
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development