🚀 Day 6 of Learning JavaScript Today I explored one of the most important core concepts in JavaScript — Functions and how JavaScript handles memory behind the scenes ✅ Functions in JavaScript: → Functions don’t need return type declaration (JS is loosely typed) ▫️Syntax: function name(parameters){ // function body return value } ✅ Types of Functions: 🔹Function Declaration 🔹Function Expression 🔹Arrow Functions (=>) 🔹IIFE (Immediately Invoked Function Expression) ✅ Execution Context & Memory Perspective: → When a JavaScript program starts, Global Execution Context (GEC) is created in the stack. → It stores all declarations (variables and function signatures) that exist outside function blocks. 🔸Function Execution: → Every time a function is called, it creates its own execution context on the stack. → This is where local variables defined within that function are allocated memory. 🔸Function Scope: → Variables created within a function (e.g., let c) are function scoped. → They cannot be accessed outside the function. → If you try to access them, it results in a "ReferenceError", as the variable is not defined in GEC. 🔸Memory Deallocation: → Once a function completes execution and control moves to the next line, its execution context is deallocated (removed from the stack). → This also removes its local variables, which is why they cannot be accessed after the function call. → Finally, the call stack is cleared once the entire program finishes execution. Thank you to Harshit T sir. #webdevelopment #JavaScript #Learning #frontend
JavaScript Functions & Memory Management
More Relevant Posts
-
Day 39/100 – JavaScript Learning 🚀 Today I learned about one of the most important JavaScript concepts that explains how functions really work: 👉 Closures in JavaScript A closure is created when a function remembers variables from its outer scope, even after that outer function has finished executing. Example: function outer() { let count = 0; function inner() { count++; console.log(count); } return inner; } const counter = outer(); counter(); // 1 counter(); // 2 Even though outer() has finished running, the inner() function still has access to count. That’s a closure. Why closures matter: Used in callbacks and event handlers Helps with data privacy Common in React hooks and real applications Very popular interview topic Understanding closures made me realize that JavaScript doesn’t “forget” variables — it remembers context. This concept felt confusing at first, but once it clicked, a lot of JavaScript behavior started making sense. Learning one concept deeply is better than rushing many. #JavaScript #WebDevelopment #Closures #100DaysOfCode #LearningInPublic #Day39
To view or add a comment, sign in
-
-
🚀 JavaScript Learning Journey – Day 17 🚀 Continuing my JavaScript learning by understanding Callbacks and Callback Hell, which explain how asynchronous tasks were handled earlier in JavaScript. 🔹 Callbacks Definition: A callback is a function passed as an argument to another function and executed later, usually after an asynchronous task completes. Real-World Examples: Executing code after data is fetched Handling user actions like button clicks Running logic after a timer completes 🔹 Callback Hell Definition: Callback Hell occurs when multiple callbacks are nested inside each other, making code hard to read, debug, and maintain. Real-World Scenario: Multiple dependent API calls written using nested callbacks 💡 Key Takeaway: Callbacks work, but excessive nesting leads to poor readability and maintenance issues. #JavaScript #Callbacks #AsynchronousJS #WebDevelopment #FrontendDeveloper #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Day 40/100 – JavaScript Learning 🚀 Today I learned about an important JavaScript concept that explains how code is executed behind the scenes: 👉 The Call Stack The call stack is a mechanism JavaScript uses to keep track of function execution. Every time a function is called, it is added to the stack. When the function finishes, it is removed from the stack. Example: function first() { second(); } function second() { console.log("Hello"); } first(); Execution order: first() is added to the stack second() is added on top of it console.log() runs second() is removed first() is removed 💡 Key points I learned: JavaScript uses a single call stack Functions run one at a time A blocked stack can freeze the application Stack overflow happens when too many calls are made Understanding the call stack makes it easier to: Debug errors Understand recursion Learn asynchronous JavaScript Read error stack traces This topic made JavaScript feel less mysterious and more logical. Strong fundamentals build strong developers. 💪 #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic #CallStack #Day40
To view or add a comment, sign in
-
-
🎉 JavaScript Series – Now Live! 🎉 Many students were asking for a JavaScript series, and I’m happy to share that the JavaScript Playlist is finally live on YouTube! 🚀 This series is designed to help students learn JavaScript step-by-step, from basics to advanced, with clear explanations and practical examples. 📌 Why this playlist is useful: ✅ Structured learning with proper flow ✅ Strong fundamentals for JavaScript ✅ Helpful for beginners and aspiring web developers If you’re interested in Web Development or want to strengthen your JavaScript skills, make sure to check it out. Abhishek Tiwari Ashish Kumar Priya Singh Rajput Pooja Kannaujiya Gargi Rai Medinee Gupta Nitin Tiwari 👉 Playlist link is in the comments
To view or add a comment, sign in
-
-
🗓️Day 23/100 – Most Important JavaScript Questions Everyone Should Know 🚀 Still learning JavaScript and feeling confused sometimes? Same here. So today I noted down the most important JS questions every learner should understand (not just memorize). 📌 Javascript Question and Answer Q1. What is the difference between var, let, and const? Ans: var is function scoped and can be re-declared. let is block scoped and can be updated but not re-declared. const is block scoped and cannot be updated or re-declared. --- Q2. What is hoisting in JavaScript? Ans: Hoisting means JavaScript moves variable and function declarations to the top of their scope before execution. --- Q3. What is a closure? Ans: A closure is a function that remembers variables from its outer scope even after the outer function has finished executing. --- Q4. Difference between == and ===? Ans: == compares only values (type conversion happens). === compares both value and data type. --- Q5. What is event bubbling? Ans: Event bubbling means an event starts from the target element and moves upward to parent elements. --- Q6. What is scope in JavaScript? Ans: Scope defines where a variable can be accessed in the code. Types: Global, Function, and Block scope. --- Q7. What is a callback function? Ans: A callback function is a function passed as an argument to another function and executed later. --- Q8. What is a promise? Ans: A promise is an object that represents the result of an asynchronous operation. States: Pending, Fulfilled, Rejected. --- Q9. What is async/await? Ans: Async/await is a modern way to handle asynchronous code using promises, making code easier to read and write. --- Q10. Difference between null and undefined? Ans: undefined means a variable is declared but not assigned a value. null means the variable is intentionally set to empty. --- Final Note 💡 Strong JavaScript basics build strong developers. Learning slowly but clearly ✔️ #Day23 #JavaScript #JSInterview #100DaysOfCode #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
JAVASCRIPT Tea Episode 1: Javascript Keywords As part of my learning journey in JavaScript, I explored some key keywords and why certain practices are better avoided. JavaScript is the language that brings websites to life, making them interactive, dynamic, and responsive to user actions. At its core, it has a set of keywords that act like the building blocks of your code. They control logic, manage variables, and guide how data flows. Knowing how these keywords work is essential for writing code that’s not just functional, but clean, predictable, and easy to maintain. Here are 15 JavaScript keywords and what they do: 1. let – declares a block-scoped variable. Safer than var. 2. const – declares a constant variable that cannot be reassigned. 3. var – declares a function-scoped variable (older practice, less recommended). 4. if – runs code when a condition is true. 5. else – runs code when the if condition is false. 6. switch – evaluates an expression and runs code based on cases. 7. case – defines a block in a switch. 8. default – fallback code in a switch. 9. for – loop that runs code a set number of times. 10. while – loop that runs as long as a condition is true. 11. function – declares a reusable block of code. 12. return – exits a function and optionally returns a value. 13. break – exits a loop or switch immediately. 14. continue – skips the current loop iteration. 15. try / catch – handles errors; try runs code, catch handles errors. I also learned why using var to declare variables is discouraged in modern Javascript: 1. It is function-scoped, not block-scoped, which can cause unexpected behavior. 2. Hoisting can lead to variables being used before they are declared. 3. You can accidentally redeclare the same variable in the same scope. 4. It makes code less predictable and harder to maintain. Understanding these basics makes writing cleaner, safer, and more efficient JavaScript code. #JavaScript #WebDevelopment #Programming #TechLearning #Coding #SoftwareDevelopment The Curve Africa
To view or add a comment, sign in
-
🚀 Today’s Learning: JavaScript this Keyword Today I learned about the this keyword in JavaScript and how its value changes based on different contexts 👇 🔹 Global scope 🔹 Inside functions 🔹 Event handlers 🔹 Classes & methods To understand it better, I didn’t just stop at theory — I built a small project 💻 Users can enter details like name, bio, role, and URL, and the UI gets updated dynamically on the page. This project helped me clearly understand one important concept: 👉 this depends on how a function is called, not where it is written. Learning by building makes concepts stick better 🙌 Looking forward to exploring more JavaScript concepts and improving my skills. #JavaScript #ThisKeyword #FrontendDevelopment #WebDevelopment #LearningByDoing #DeveloperJourney #HandsOnProject
To view or add a comment, sign in
-
Have you ever noticed that learning JavaScript feels smooth at first, until it suddenly doesn't? 🤔 At the beginning, variables click and functions behave as expected. You're cruising along. Then closures, async code, 'this', and mental models show up, and it feels like you've hit a wall. The thing most dev learners and junior developers never hear? That moment of confusion isn't failure; it's a signal. 🚨 JavaScript has a unique learning curve. Not because the syntax is overly complex, but because the rules quietly change. What used to work (memorizing, following tutorials, copying patterns) stops being enough when JavaScript concepts begin to rely on how you think, rather than what you remember. That's why progress can feel non-linear, why your confidence dips right when you're actually leveling up, and why so many beginners assume they're "slow" when they're actually not. So here's the real question: What if the frustration you're feeling is proof that real learning has finally started? 🚀 Find out why this happens and what it means for your JavaScript progress here: https://lnkd.in/dNR3mwkp
To view or add a comment, sign in
-
🚀 JavaScript Learning Journey – Day 10 🚀 Continuing my JavaScript learning by understanding Prototypes, a core concept behind JavaScript’s object-oriented behavior. 🔹 Prototypes in JavaScript Definition: In JavaScript, every object has a prototype, which is another object from which it inherits properties and methods. 🔹 Why Prototypes Matter • Prototypes enable inheritance in JavaScript • They help reuse methods instead of duplicating them for every object • This improves memory efficiency and performance 🔹 How Prototypes Work (Conceptually) • When a property or method is not found on an object, JavaScript looks for it in its prototype • This lookup continues up the prototype chain until it is found or reaches null 🔹 Real-World Examples • Common methods like toString() or push() are available because of prototypes • Custom objects can share common behavior using prototypes • Frameworks and libraries heavily rely on prototypes for reusable functionality 💡 Key Takeaways: Prototypes are the foundation of inheritance and code reuse in JavaScript. Understanding them is essential for mastering objects, classes, and advanced JavaScript concepts. 📌 Strengthening JavaScript fundamentals to better understand how the language works internally. #JavaScript #Prototypes #WebDevelopment #FrontendDeveloper #Programming #LearningInPublic #DeveloperJourney #CareerGrowth #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