Function declarations and function expressions look almost identical, but JavaScript treats them differently under the hood, especially because of hoisting. So I wrote a short blog explaining: • What functions are and why we use them • Function declaration syntax • Function expression syntax • Key differences between the two • A simple explanation of hoisting • When to use each approach If you are starting with JavaScript, this distinction will save you from some confusing bugs later 👇 https://lnkd.in/gpYx4vyy Thanks to Nikhil Rathore Hitesh Choudhary Chai Aur Code Piyush Garg Akash Kadlag Jay Kadlag for guidance! #JavaScript #WebDevelopment #LearnInPublic #100DaysOfCode #FrontendDevelopment #Programming #CodingJourney #Developers #TechBlog
JavaScript Function Declarations vs Expressions: Understanding Hoisting
More Relevant Posts
-
Most JavaScript bugs don’t come from syntax… They come from 𝐦𝐢𝐬𝐮𝐧𝐝𝐞𝐫𝐬𝐭𝐚𝐧𝐝𝐢𝐧𝐠 𝐬𝐜𝐨𝐩𝐞. Why does `var` behave differently from `let`? Why do closures “remember” variables? Why do some variables leak into global scope? If these questions have ever confused you, this is worth reading. Read here: https://lnkd.in/gybfSz6F #JavaScript #Coding #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Just Published: Blog 5 of Javascript blog series Understanding Functions in JavaScript (Beginner Friendly) Functions are one of the most important building blocks in JavaScript—but many beginners struggle with: 👉 Function Declaration vs Function Expression 👉 When to use which 👉 Why some functions work before defining (hoisting) So I wrote a simple, practical guide to understand JS functions. Blog Link: https://lnkd.in/gJQMHUgt Hitesh Choudhary Piyush Garg and Chai Aur Code team Would love your feedback 🙌 #JavaScript #WebDevelopment #Coding #LearnToCode #Programming
To view or add a comment, sign in
-
Just published a new blog on Arrow Functions in JavaScript. In this article, I covered: • What arrow functions are • Basic arrow function syntax • Arrow functions with single and multiple parameters • Implicit return vs explicit return • The basic difference between arrow functions and normal functions • Simple examples and exercises for practice If you're learning JavaScript, understanding arrow functions is an important step toward writing cleaner and more modern code 👇 https://lnkd.in/gz_gny9C #JavaScript #WebDevelopment #FrontendDevelopment #LearnInPublic #CodingJourney #100DaysOfCode #SoftwareDevelopment #Programming
To view or add a comment, sign in
-
🚀 JavaScript Fundamentals Series — Part 4 Functions are where JavaScript becomes powerful and reusable. Instead of repeating code, functions let you create reusable logic blocks. In this guide you'll learn: • What functions actually are • Parameters vs arguments • Return values • Function declarations vs expressions • How functions organize your code Functions are the foundation of almost everything in JavaScript. Full guide 👇 https://lnkd.in/dtgFaW2r #javascript #webdevelopment #coding
To view or add a comment, sign in
-
getElementById vs querySelector in JavaScript When working with the DOM, selecting elements efficiently is very important. Two commonly used methods are getElementById() and querySelector() — but they are not the same. In this article, I explain: • How each method works • Key differences between them • Performance considerations • Practical examples for developers If you’re learning JavaScript, Frontend Development, or preparing for interviews, this comparison will help you understand the concept clearly. 📘 Read the full article: 👉 https://lnkd.in/g_udtdb8 #JavaScript #FrontendDevelopment #WebDevelopment #Programming #Coding #SoftwareDevelopment
To view or add a comment, sign in
-
Objects are the backbone of JavaScript! 🧩 I just published a blog on JavaScript Objects. In this post: ✅ Key–Value pairs ✅ Dot vs Bracket notation ✅ Adding, updating, and deleting properties Read it here 👇 👉 https://lnkd.in/e94afMk4 #JavaScript #WebDev #LearningInPublic #Coding
To view or add a comment, sign in
-
🚀 Day 5 / 100 — JavaScript Concepts That Every Developer Should Understand #100DaysOfCode Today I revised two very important JavaScript concepts that often come up in interviews and real-world debugging: 🔐 1. Closures A closure happens when a function remembers variables from its outer scope even after the outer function has finished executing. In simple words: A function carries its environment with it. Example: function outer() { let count = 0; function inner() { count++; console.log(count); } return inner; } const counter = outer(); counter(); // 1 counter(); // 2 counter(); // 3 Why this works: Even though outer() has finished running, inner() still remembers the variable count. 📌 Common use cases • Data privacy • Function factories • React hooks • Event handlers 🧠 2. Call Stack The call stack is how JavaScript keeps track of function execution. It works like a stack (Last In, First Out). Whenever a function runs: 1️⃣ It gets pushed onto the stack 2️⃣ When it finishes, it gets popped off Example: function one() { two(); } function two() { three(); } function three() { console.log("Hello from the call stack"); } one(); Execution order in the call stack: Call Stack three() two() one() global() Then it unwinds after execution. 📌 Understanding the call stack helps with: • Debugging errors • Understanding recursion • Avoiding stack overflow 💡 Key realization today: JavaScript is single-threaded, and concepts like closures + call stack explain a lot about how the language actually works behind the scenes. Mastering these fundamentals makes async JS, promises, and the event loop much easier later. 🔥 Day 5 completed. 95 days to go. If you're also learning to code, comment “100” and let’s stay consistent together 🤝 #javascript #100daysofcode #webdevelopment #coding #developers #programming #learninpublic #buildinpublic #SheryiansCodingSchool #Sheryians
To view or add a comment, sign in
-
-
🚀 Just published a new blog on Function Declaration vs Function Expression in JavaScript. In this article, I explain the difference between function declarations and function expressions, how each syntax works, and when to use them. I also covered the basic idea of hoisting with simple examples to make the concept easy for beginners. 📖 Read the full article here: https://lnkd.in/g3Acgus7 Inspired by the amazing teaching of Hitesh Choudhary Sir and Piyush Garg Sir from Chai Aur Code. ☕💻 #javascript #webdevelopment #learninginpublic #chaiAurCode
To view or add a comment, sign in
-
Frontend Learning — Understanding Event Loop in JavaScript JavaScript is single-threaded, but still handles async tasks like APIs, timers, and promises smoothly — thanks to the Event Loop. -> So how does it actually work? 1️⃣ Call Stack – Executes synchronous code line by line 2️⃣ Web APIs – Handles async tasks (setTimeout, fetch, etc.) 3️⃣ Callback Queue – Stores callbacks from async operations 4️⃣ Microtask Queue – Stores promises (.then, catch) 5️⃣ Event Loop – Decides what runs next -> Execution Priority: First → Call Stack Then → Microtasks (Promises) Then → Macrotasks (setTimeout, setInterval) -> Why this matters: Understanding this helps you debug async issues, optimize performance, and write predictable code. -> Key Takeaway: Promises always execute before setTimeout (even with 0 delay). #JavaScript #FrontendDevelopment #WebDevelopment #AsyncJavaScript #EventLoop #CodingTips #LearnInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
Are you still using traditional string concatenation in JavaScript? It works… but it quickly becomes messy and hard to maintain. In this article, I break down how Template Literals simplify your code with: • Cleaner syntax • Embedded variables & expressions • Multi-line strings • Practical modern use cases If you're learning or working with JavaScript, this is a must-know concept. Read here 👉 https://lnkd.in/gHEZrAhX #JavaScript #Programming #WebDevelopment #Frontend #Coding
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