Imagine the below piece of JS code, what will the user experience? Hint: Answer lies in the understanding of the Event loop. #javascript
Understanding JavaScript Event Loop
More Relevant Posts
-
https://lnkd.in/dgECwK-b Day 57/100 🚀 Refactored my AttendTrack project — improved the layout, fixed the counting functionality, and converted it into a PWA so it can work offline. #100DaysOfCode #JavaScript #WebDev
To view or add a comment, sign in
-
Most developers use forEach() and map() interchangeably — but they are NOT the same. ✔ Use forEach() for side effects ✔ Use map() for transformation ✔ Prefer map() when you need a new array Understanding this difference shows strong JavaScript fundamentals. #JavaScript #Frontend #WebDevelopment #CodingInterview #TechInterview
To view or add a comment, sign in
-
-
Just published a new article on responsive images for better web performance. A practical guide to srcset, sizes, modern image formats, and improving Core Web Vitals without over-engineering. 💬 Thoughts? Link in the first comment! #WebPerformance #FrontendDevelopment #JavaScript #ResponsiveImages #CoreWebVitals #WebDev
To view or add a comment, sign in
-
-
JavaScript question 🧠 What will this log? Think before running it. const values = [ 0, -0, +0 ]; const set = new Set( values ); console.log( set.size ); A) 1 B) 2 C) 3 Are 0, -0, and +0 treated as different values? Or does Set see them as the same? #JavaScript #CodingChallenge #Frontend
To view or add a comment, sign in
-
-
🚀 30 Days of JavaScript Tricky Questions – Day 1 Let’s start with async / await + event loop 🧠 async function foo() { console.log('A'); setTimeout(() => console.log('B'), 0); await Promise.resolve(); console.log('C'); } foo(); console.log('D'); ❓ What will be the output and why? 💬 Drop your answer in the comments #JavaScript #JSInterview #AsyncJavaScript #FrontendDeveloper #WebDevelopment #30DaysOfJavaScript
To view or add a comment, sign in
-
Started from console errors… Ended with a working calculator. 😄 Today I built a calculator using HTML, CSS & JavaScript. While building this, I learned: Why == behaves differently than === How JavaScript handles type coercion How to structure UI using Flexbox How to debug runtime errors effectively It’s a small project, but every small project builds big confidence. On to the next one 🚀 #CodingJourney #FrontendDevelopment #JavaScript
To view or add a comment, sign in
-
⚡ Day 3 – querySelector vs querySelectorAll (Real Difference) Both methods use CSS selectors. But they return different results — and that difference matters. 🔹 querySelector() ✔ Uses CSS selectors ✔ Returns the first matching element ✔ Returns a single element ✔ Stops after first match 🔹 querySelectorAll() ✔ Uses CSS selectors ✔ Returns all matching elements ✔ Returns a NodeList ✔ Can loop using forEach() 🧠 Key Difference: querySelector() → first match only querySelectorAll() → all matching elements ⚠️ Important: A NodeList is not an Array, but it supports forEach(). Understanding small DOM differences like this helps avoid common bugs and builds a strong JavaScript foundation. #JavaScript #WebDevelopment #Frontend #DOM #JSConcepts #Coding #100DaysOfCode
To view or add a comment, sign in
-
-
💡HTML Tip💡 Want to make your dropdowns more organized? Use the <optgroup> tag inside the <select> tag to group related options — no need to use any external library to achieve this! 🙌 It's a simple, built-in HTML feature that makes your forms much cleaner and more user-friendly. 🚀 𝗖𝗵𝗲𝗰𝗸 𝗼𝘂𝘁 𝘁𝗵𝗲 𝗖𝗼𝗱𝗲𝗣𝗲𝗻 𝗱𝗲𝗺𝗼 𝗹𝗶𝗻𝗸 𝗶𝗻 𝘁𝗵𝗲 𝗰𝗼𝗺𝗺𝗲𝗻𝘁 𝘁𝗼 𝘀𝗲𝗲 𝗶𝘁 𝗶𝗻 𝗮𝗰𝘁𝗶𝗼𝗻. 𝘍𝘰𝘳 𝘮𝘰𝘳𝘦 𝘴𝘶𝘤𝘩 𝘶𝘴𝘦𝘧𝘶𝘭 𝘤𝘰𝘯𝘵𝘦𝘯𝘵, 𝘥𝘰𝘯'𝘵 𝘧𝘰𝘳𝘨𝘦𝘵 𝘵𝘰 𝘧𝘰𝘭𝘭𝘰𝘸 𝘮𝘦. #html #javascript #reactjs #nexjs #webdevelopment
To view or add a comment, sign in
-
-
frameworks and libraries is all about syntax, the real deal is knowing what powers them... useEffect and useState are dangerous syntax to someone who doesn't understand how window loaded and DomContent event listeners work in pure javaScript... Axios is great but if you dont know how the fetch API works, the you would struggle to undertstand how the browser handles http errors... Knowing the fundamentals isn't about going back to the stone age, its what you need to build with confidence. #reactjs #frontend #javaScript
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
Answer: JS is single-threaded so it relies on the event loop for handling concurrency without blocking the main thread. It has 3 parts - the call stack, the macrotask queue and the microtask queue. Micro tasks take the highest priority because they are interpreted as small and easy tasks so the event loop drains the micro task queue before yielding back to the browser for rendering. In the above function, each microtask schedules another microtask, and the queue never empties. This creates an infinite chain of microtasks. Since the event loop must fully drain the microtask queue before rendering, the browser never gets a chance to paint the UI and it appears frozen to the user.