Why does JavaScript show "undefined"? If you’ve seen this, you’ve already faced Hoisting. I broke it down in the simplest way possible 👇 ✔ JavaScript runs in 2 phases ✔ var is hoisted with undefined ✔ let & const are hoisted but not initialized (TDZ) 💡 Rule: Always declare variables before using them Save this for revision 📌 #javascript #webdevelopment #frontend #coding #reactjs
JavaScript Hoisting Explained
More Relevant Posts
-
Six characters that completely changed how we write JavaScript. 👇 If your code is still cluttered with the function keyword, it’s time for an upgrade. Arrow functions () => {} aren't just syntactic sugar; they are the backbone of clean, modern JS. Swipe through the carousel to see: - Why developers prefer them - How they fix the classic this headache - Where they shine the most How often are you using arrow functions in your current projects? #JavaScript #WebDev #CleanCode #Frontend #Coding
To view or add a comment, sign in
-
🚀 JavaScript Output Challenge #4 (Trap Level) If you think you understand JavaScript deeply… this one will test you 👇 🧠 Question: (Check the code in the images) ⚠️ Rules: Don’t run the code Think step by step Focus on execution order 🤔 Try to answer: What will be the exact output? Why does it happen? What changes if we replace var with let? 💬 Drop your answers in the comments Let’s see how many get this right 👀 🔥 Concepts involved: Event Loop Microtask vs Macrotask Closures Scope (var vs let) 📌 I’ll share the detailed explanation soon #javascript #webdevelopment #frontend #codingchallenge #reactjs #nodejs
To view or add a comment, sign in
-
-
JavaScript scoping still breaks more code than people admit. Not because developers don’t know syntax. Because they assume var behaves like let. It doesn’t. let / const → block scope var → function scope That tiny difference still causes: - hidden bugs - confusing loops - unexpected values in legacy code If you work with older JavaScript codebases, this still matters a lot. Do you still see var in production code or is it finally gone? 👇 #javascript #frontend #webdevelopment #reactjs #coding
To view or add a comment, sign in
-
-
JavaScript scoping still breaks more code than people admit. Not because developers don’t know syntax. Because they assume var behaves like let. It doesn’t. let / const → block scope var → function scope That tiny difference still causes: - hidden bugs - confusing loops - unexpected values in legacy code If you work with older JavaScript codebases, this still matters a lot. #javascript #frontend #webdevelopment #reactjs #coding
To view or add a comment, sign in
-
We all use try...catch in JavaScript. But do we really understand it? 👀 I recently explored some surprising behaviors: finally can override your return 🤯 1. try-catch doesn’t handle async errors ❌ 2. catch is actually optional 😳 These small nuances can save you from production bugs. Wrote a simple and practical breakdown 👇 https://lnkd.in/g7NQJzcT Would love your feedback 🙌 #javascript #webdevelopment #frontend #coding #learninpublic
To view or add a comment, sign in
-
-
💻 JavaScript Array Methods – Hands-on Practice Completed Worked on some fundamental Array methods in JavaScript and practiced how they actually behave 👇 ✔️ Used push() and pop() to add/remove elements from the end ✔️ Used unshift() and shift() to work with elements at the beginning ✔️ Explored length to track array size ✔️ Understood the difference between slice() and splice() through practice 💡 Key takeaway: slice() does not modify the original array, while splice() directly changes it — this difference is really important while working with data. Practicing these basics is helping me build a strong foundation in JavaScript 🚀 #JavaScript #WebDevelopment #Frontend #CodingJourney #LearningByDoing
To view or add a comment, sign in
-
-
What is a closure in JavaScript? A closure is a function that remembers variables from its outer scope even after that scope has finished executing. Why does this work? - `createCounter` runs once - It creates a variable `count` - The inner function “closes over” that variable - Even after `createCounter` finishes, `count` is still accessible Each time `counter()` runs: → it uses the same preserved state 💡 Closures are everywhere: - React hooks - Event handlers - Memoization - Encapsulation patterns They’re not just a concept — they’re part of how JavaScript manages state. #Frontend #JavaScript #React #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
JavaScript is simple… until it isn’t 😅 Here are a few things that confused me (and probably you too): 👉 [] + [] = "" 👉 [] + {} = "[object Object]" 👉 {} + [] = 0 And the classic: 👉 typeof null === "object" 🤯 JavaScript isn’t weird… it’s just misunderstood. Once you understand type coercion, execution context, and closures, everything starts making sense. 💡 My advice: Don’t just “use” JavaScript — understand how it works internally. What’s the most confusing JS behavior you’ve faced? 👇 #javascript #webdevelopment #frontend #programming
To view or add a comment, sign in
-
Day 3 ⚡ JavaScript Promises — Quick Revision If you're learning async JavaScript, understanding Promises is a must. --- 🧠 What is a Promise? 👉 A Promise represents a value that will be available now, later, or never --- 🔄 Promise States Pending ⏳ Fulfilled ✅ Rejected ❌ --- ✅ Basic Example const promise = new Promise((resolve, reject) => { resolve("Success"); }); --- 🎯 Using Promises promise .then(res => console.log(res)) .catch(err => console.log(err)); --- 🔗 Chaining (Very Important) Promise.resolve(2) .then(res => res * 2) .then(res => res + 5) .then(res => console.log(res)); // 9 👉 Each .then() must return a value --- ⚠️ Common Mistakes ❌ Not returning inside .then() ❌ Breaking the chain ❌ Delaying .then() instead of resolve() --- 💡 One-line takeaway: 👉 Promises help you control async code step-by-step --- Master this, and async JavaScript becomes much easier 🚀 #JavaScript #WebDevelopment #Frontend #Coding #100DaysOfCode
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
JavaScript be like: I exist… but I don’t know who I am yet 🤡😂