🧠 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻 (𝗚𝗖) — 𝗤𝘂𝗶𝗰𝗸 𝗜𝗻𝘀𝗶𝗴𝗵𝘁 JavaScript automatically manages memory using 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻 ✅ Most JS engines (like V8) use the 𝗠𝗮𝗿𝗸-𝗮𝗻𝗱-𝗦𝘄𝗲𝗲𝗽 𝗮𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺: ✅ 𝗠𝗮𝗿𝗸: GC starts from root references (global scope, current stack, closures) and marks all 𝗥𝗲𝗮𝗰𝗵𝗮𝗯𝗹𝗲 objects. ✅ 𝗦𝘄𝗲𝗲𝗽: 𝗨𝗻𝗿𝗲𝗮𝗰𝗵𝗮𝗯𝗹𝗲 objects are removed from memory. ⚠️ 𝗖𝗼𝗺𝗺𝗼𝗻 𝗺𝗲𝗺𝗼𝗿𝘆 𝗹𝗲𝗮𝗸 𝗿𝗲𝗮𝘀𝗼𝗻𝘀: ✔ Unremoved event listeners ✔ Uncleared setInterval() / timers ✔ Closures holding large references ✔ Accidental global variables Understanding GC helps build 𝗳𝗮𝘀𝘁𝗲𝗿, 𝘀𝘁𝗮𝗯𝗹𝗲, 𝗮𝗻𝗱 𝗺𝗲𝗺𝗼𝗿𝘆-𝗲𝗳𝗳𝗶𝗰𝗶𝗲𝗻𝘁 apps 🚀 #JavaScript #FrontendDevelopment #Performance #MemoryManagement #V8 #WebDevelopment #SoftwareEngineering
JavaScript Memory Management with V8 Garbage Collection
More Relevant Posts
-
🚀 Day 924 of #1000DaysOfCode ✨ Sorting in JavaScript — Beyond Just `.sort()` Sorting looks simple at first — just call `.sort()` and you’re done, right? Not exactly. In today’s post, I’ve explained sorting in JavaScript in a clear and practical way. From how the default sorting works to how custom compare functions change behavior, everything is broken down so you can confidently sort numbers, strings, and even complex objects. If you’ve ever been surprised by unexpected sorting results, this post will help you understand why that happens. 👇 What’s the most complex data you’ve had to sort in JavaScript? #Day924 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #Next #CodingCommunity
To view or add a comment, sign in
-
Built a small project to deeply understand how Local Storage works in JavaScript. Implemented: • Loading stored data on page refresh • Syncing input field with saved values • Updating storage dynamically using the input event • Removing specific keys using removeItem() • Handling null values safely This helped me understand how browser storage persists data and how to properly connect it with the DOM. Strong fundamentals lead to better full-stack development. 💻 #JavaScript #LocalStorage #WebDevelopment #FrontendDevelopment #BrowserStorage #CodingJourney #LearnInPublic #MERNStack #SoftwareEngineering #100DaysOfCode #TechLearning
To view or add a comment, sign in
-
🚀#Day45 #100Daysofcode – Introduction to Templating with EJS Today I started working with EJS (Embedded JavaScript) and understood how templating works in backend development. 🔹learned today: • What templating is and why it’s needed • How to use EJS with Express • Setting up the views directory • Understanding interpolation syntax: <%= %> for output <% %> for logic • Passing dynamic data from backend to EJS templates 💡Key Understanding: Instead of sending only JSON responses, the server can now render dynamic HTML pages using data. This helped me understand how backend and frontend connect in server-side rendering. #Day45complete✅👍🏻 #ExpressJS #NodeJS #BackendDevelopment #MERNStack #100DaysOfCode #WebDevelopment
To view or add a comment, sign in
-
-
🚀 How JavaScript Works Behind the Scenes (Short Version) JavaScript looks simple, but internally a lot is happening. • V8 Engine (Chrome & Node.js) It converts JS into machine code and runs it. Uses: Call Stack → Executes synchronous code Heap → Stores objects & memory • Web APIs + Event Loop Async tasks like setTimeout, fetch, and DOM events go to Web APIs. After completion: Promises → Microtask Queue Timers/Events → Callback Queue The Event Loop moves them to the Call Stack when it's empty. • Garbage Collection V8 uses Mark & Sweep to remove unused memory. Poor reference handling can cause memory leaks. Client vs Server Browser → V8 + Web APIs Node.js → V8 + libuv (async I/O, worker threads) Understanding this helps in writing optimized, scalable, and industry-ready JavaScript. #JavaScript #V8 #EventLoop #WebDevelopment Vikas Kumar Pratyush Mishra
To view or add a comment, sign in
-
𝗗𝗮𝘆 𝟯 𝗼𝗳 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 🚀 Today I explored 𝗠𝗲𝗺𝗼𝗿𝘆 𝗠𝗮𝗻𝗮𝗴𝗲𝗺𝗲𝗻𝘁 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁, and it was eye-opening! Here’s what I learned about how memory is organized: • 𝗦𝘁𝗮𝗰𝗸 – stores primitive values like numbers and strings, with fast access • 𝗛𝗲𝗮𝗽 – stores objects, arrays, and reference types, which are larger and more flexible • 𝗦𝗠𝗜 (Small Integers) – a clever optimization where JavaScript stores small numbers efficiently to save memory and improve performance Understanding these concepts gives me a deeper appreciation for how JavaScript works under the hood and helps me write cleaner, more efficient code. #JavaScript #WebDevelopment #100DaysOfCode #LearningJourney #FrontendDevelopment
To view or add a comment, sign in
-
-
JavaScript TDZ — Where are var, let, and const stored? 🧠 When JS runs, it creates an Execution Context ⚙️ with two memory areas: 1️⃣ Global Object Environment 🌍 → var variables go here → attached to the global object (like window in browsers) → auto-initialized with undefined ✅ 2️⃣ Script / Lexical Environment 📦 → let and const go here → block-scoped memory space → memory reserved but not initialized 🚫 (TDZ ⏳) That’s why: var before declaration → undefined let/const before declaration → error ⛔ JS separates them to enforce block scope and reduce bugs 🛡️ #JavaScript #JSCore #ExecutionContext
To view or add a comment, sign in
-
I practiced destructuring in JavaScript, and it’s a very useful feature. Using destructuring, we can easily extract values from arrays and objects. For arrays, we use square brackets []. For objects, we use curly braces {}. In arrays, values are assigned based on their position, and in objects, they are assigned based on property names. Such a clean and efficient way to work with data. #JavaScript #Destructuring #ES6 #WebDevelopment #LearningJourney
To view or add a comment, sign in
-
🚀 A Subtle JavaScript Array Bug This looks harmless: const arr = [1, 2, 3]; const copy = arr; copy.push(4); console.log(arr); Output? [1, 2, 3, 4] Why did the original array change? Because arrays (like objects) are reference types in JavaScript. copy is not a new array. It points to the same memory location. This can create unexpected side effects in larger applications. ✅ Better approach: const arr = [1, 2, 3]; const copy = [...arr]; copy.push(4); console.log(arr); // [1, 2, 3] Now you’re working with a new reference. In JavaScript, copying data is not always copying values. Sometimes it’s copying references. Understanding this saves hours of debugging. What JS concept took you the longest to truly understand? #javascript #frontenddeveloper #webdevelopment #coding #softwareengineering
To view or add a comment, sign in
-
-
Intercept, Control, Reflect: Power Tools Hidden in JavaScript 🪞 Learned about the Proxy pattern in JavaScript and how it works closely with the Reflect object. Explored how Proxies allow interception of operations like: -Property access -Assignment -Validation -Logging or access control And how Reflect provides a clean, predictable way to forward those operations while preserving default behavior. Key takeaway: Proxies are powerful but sharp tools. They enable elegant abstractions, yet can hurt readability and debugging if overused. Reflect helps keep proxy logic explicit and intention-revealing. Understanding these internals deepens how JS really works under the hood. #JavaScript #DesignPatterns #ProxyPattern #FrontendDevelopment #WebDevelopment #LearnInPublic
To view or add a comment, sign in
-
How JavaScript engines actually handle arrays, and there’s a lot of hidden logic going on. ⚙️ The main thing is the difference between Packed (continuous) and Holey (arrays with empty gaps). Here is what I learned: SMI is the best: Arrays with only small integers are the most optimized. One-way downgrade: If you add a float or string to an integer array, the engine downgrades its optimization. Even if you remove that item later, it doesn't go back to being as fast as it was. Holes are costly: When JS hits an empty gap, it has to check all the way up the prototype chain to find a value. It’s one of the most expensive operations in the engine. A simple tip I learned: Avoid using "new Array(3)" because it creates holes immediately. Starting with [ ] keeps things much more optimized. #LearningInPublic #Javascript #WebDev
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