𝗪𝗲𝗹𝗰𝗼𝗺𝗲 𝘁𝗼 𝗗𝗮𝘆 𝟭𝟯 𝙃𝙤𝙬 𝙅𝙖𝙫𝙖𝙎𝙘𝙧𝙞𝙥𝙩 𝙂𝙖𝙧𝙗𝙖𝙜𝙚 𝘾𝙤𝙡𝙡𝙚𝙘𝙩𝙞𝙤𝙣 𝙒𝙤𝙧𝙠𝙨 Your code doesn’t free memory. JavaScript does. But it only removes what is unreachable. 𝙍𝙚𝙖𝙘𝙝𝙖𝙗𝙞𝙡𝙞𝙩𝙮 An object stays in memory if there is a reference path from the roots. Roots: • Global scope • Execution stack • Active closures No path → eligible for garbage collection. 𝙈𝙖𝙧𝙠 & 𝙎𝙬𝙚𝙚𝙥 • Start from the roots and mark all reachable objects • Remove everything unmarked Reachable stays. Unreachable is freed. 𝙂𝙚𝙣𝙚𝙧𝙖𝙩𝙞𝙤𝙣𝙖𝙡 𝘾𝙤𝙡𝙡𝙚𝙘𝙩𝙞𝙤𝙣 Most objects die young. Memory is divided into: • Young generation → short-lived objects, frequent fast cleanup • Old generation → long-lived objects, less frequent cleanup 𝙋𝙧𝙤𝙢𝙤𝙩𝙞𝙤𝙣 Every object starts in the young generation. If it survives multiple GC cycles or memory pressure increases, it gets promoted to the old generation. Survival determines placement. 𝙒𝙝𝙮 𝙈𝙚𝙢𝙤𝙧𝙮 𝙇𝙚𝙖𝙠𝙨 𝙎𝙩𝙞𝙡𝙡 𝙃𝙖𝙥𝙥𝙚𝙣 GC removes only unreachable objects. Leaks occur when references are retained: • Globals • Closures • Timers / event listeners • Growing caches 𝘎𝘊 𝘸𝘰𝘳𝘬𝘴 𝘤𝘰𝘳𝘳𝘦𝘤𝘵𝘭𝘺. 𝘠𝘰𝘶𝘳 𝘳𝘦𝘧𝘦𝘳𝘦𝘯𝘤𝘦𝘴 𝘥𝘦𝘤𝘪𝘥𝘦 𝘸𝘩𝘢𝘵 𝘭𝘪𝘷𝘦𝘴. #JavaScript #WebDevelopment #SoftwareEngineering #FrontendDevelopment #Programming #Coding #Developers #TechCommunity #ComputerScience #PerformanceOptimization #Learning #ContinuousLearning #LearnInPublic
Shivank MITTAL’s Post
More Relevant Posts
-
😂 𝗣𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗶𝗻 𝘁𝘄𝗼 𝗲𝗿𝗮𝘀, 𝘀𝗮𝗺𝗲 𝗽𝗿𝗼𝗯𝗹𝗲𝗺: 𝗼𝘃𝗲𝗿𝗰𝗼𝗺𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗻𝗴 𝘀𝗶𝗺𝗽𝗹𝗲 𝗹𝗼𝗴𝗶𝗰 2020: solve a basic odd/even check with a giant chain of if statements 😅 2026: wrap a tiny problem in an unnecessary abstraction / helper call 📦💀 Different style… same issue: using too much for something simple. Real lesson (and it matters) 👇 Good programming is not about writing more code. It’s not about using more libraries either. It’s about: ✅ knowing the simplest correct solution ✅ understanding built-in language features ✅ using libraries when they solve a real problem (not a 1-line one) ✅ keeping code readable, testable, and easy to maintain Libraries are powerful. 🛠️ But engineering judgment is knowing when not to add one. Sometimes the best code is: ◆ smaller ◆ boring ◆ obvious ◆ and done ✅ 💾 Save this for later 🔁 Repost if this is too real 😅 ➕ Follow Rahul Choudhary for more dev humor + practical tips w3schools.com JavaScript Mastery #Programming #SoftwareEngineering #DeveloperHumor #CleanCode #JavaScript #Coding #ProblemSolving #DeveloperMindset #WebDevelopment
To view or add a comment, sign in
-
-
🔁 One of the simplest refactors that made me a better developer. I used to write a brand new function every time requirements changed. Copy. Paste. Tweak. Repeat. It worked - but it didn’t scale. At some point I started asking a different question: “What’s actually changing here?” Most of the time, it wasn’t the structure — just the operation. So instead of rewriting logic, I abstracted it. One function. Different behavior passed in when needed. (In JavaScript terms, the outer function becomes a higher-order function, and the behavior we pass in is a callback.) That shift - from hardcoding logic to designing flexibility - was where clean code started making sense to me. Once it clicks, you begin noticing it everywhere: how libraries are designed, how experienced engineers structure systems, and why good code survives changing requirements. #JavaScript #WebDevelopment #CleanCode #Programming #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 LeetCode Problem Solved - Best Time to Buy and Sell Stock Today I solved the Best Time to Buy and Sell Stock problem on LeetCode using JavaScript with an optimized single-pass approach. 📊 Approach The goal is to determine the maximum profit from buying and selling a stock given its daily prices. The key idea is to: • Track the minimum price encountered so far • Calculate the potential profit for each day • Update the maximum profit whenever a higher profit is found This allows us to compute the result in one pass through the array. ⚡ Complexity 🔹 Time Complexity: O(n) – Traverse the prices array once 🔹 Space Complexity: O(1) – No extra data structures used ✅ Result ✔️ All test cases passed 📦 Constant space complexity Problems like this reinforce the importance of array traversal, state tracking, and optimizing brute-force solutions into efficient linear algorithms. Consistent practice with these problems strengthens DSA fundamentals and problem-solving skills for coding interviews. #leetcode #javascript #dsa #algorithms #codingpractice #softwareengineering #webdevelopment
To view or add a comment, sign in
-
-
🚀 Day 1 of My DSA Journey – Solved LeetCode Problem #66 (Plus One) 💡 Today I worked on the “Plus One” and "Single Number " problem from LeetCode using JavaScript. 🔢 1.Problem Summary: Given an array of digits representing a number, add one to the number and return the result as an array. 💭 What I Learned: • Handling edge cases (especially when digit = 9) • Understanding carry forward logic • Thinking from Right → Left (LSD to MSD) • Why simple problems test core fundamentals The interesting part? 🤯 When a digit is 9, we convert it to 0 and carry 1 to the previous digit. If all digits are 9 → we add 1 at the beginning using unshift(). Small problem. Big learning. Strong fundamentals. 💪 🔢 Problem #136 – Single Number Summary: Given an array where every number appears twice except one, find the number that appears only once. 💡 Key Learning: • XOR (^) cancels duplicates automatically • Only the unique number remains • Time Complexity = O(n), Space Complexity = O(1) ✅ • Pattern recognition is 🔑: “Duplicates cancel → Unique remains” 🎯 Goal: Solve 5 problems daily Master Data Structures & Algorithms Become interview ready for product-based companies Consistency > Motivation 🔥 #DSA #LeetCode #JavaScript #ProblemSolving #SoftwareEngineer #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Understanding Memoization in JavaScript When working with functions that perform heavy calculations, running the same computation again and again can slow down your application. This is where Memoization becomes very useful. Memoization is an optimization technique where the result of a function is stored after it is executed for the first time. If the function is called again with the same input, the stored result is returned instead of recalculating it. This helps to: ✔️ Reduce unnecessary computations ✔️ Improve performance ✔️ Make applications faster and more efficient In this example, once a value is calculated, it is saved in the cache, so the function doesn’t need to compute it again. In simple terms, Memoization remembers previous results to make future operations faster. It’s commonly used in recursive algorithms, dynamic programming, and performance optimization in JavaScript applications. #JavaScript #WebDevelopment #FrontendDevelopment #Programming #Coding #SoftwareDevelopment #Developers #TechLearning #LearnJavaScript #PerformanceOptimization #CodingJourney #TechCommunity
To view or add a comment, sign in
-
-
Continuing my journey into JavaScript, I’ve just published a new blog post! This time, I’m breaking down JavaScript Operators—the fundamental building blocks that allow us to manipulate data and build logic in our code. In this guide, I cover: ✅ Arithmetic Operators (+, -, *, /, %) – The math behind the logic. ✅ Comparison Operators (==, ===, !=, >, <) – Understanding how to evaluate conditions . ✅ Strict Equality (===) – Why type checking matters! ✅ Logical & Assignment Operators (&&, ||, !, =, +=) – Flow control and data handling. I’ve included plenty of practical examples to make these concepts stick for good. A big shoutout once again to Hitesh Choudhary sir for the incredible guidance in making these basics so clear and easy to understand. Check out the full guide here: https://lnkd.in/e7s4tANn Akash Kadlag | Jay Kadlag | #JavaScript #CodingBasics #WebDevelopment #Programming #Hashnode #TechCommunity #LearnToCode #chaiaurcode
To view or add a comment, sign in
-
-
Understanding JavaScript's array methods—map, filter, and reduce—is essential for writing efficient, readable code. These methods not only simplify data manipulation but also promote immutability and functional programming principles. In our latest blog post, we break down each method with practical examples to help you transform, filter, and aggregate data seamlessly in your projects. Whether you're a junior developer or looking to sharpen your skills, mastering these array methods can accelerate your development process and improve code quality. Let's discuss: how have you used map, filter, or reduce to solve a tricky problem in your code? #javascript #webdevelopment #programming #coding #developers Check out the actual blog here : https://lnkd.in/g_hwWRyX Note: This post was generated through an AI workflow. If you notice any issues, please contact me.
To view or add a comment, sign in
-
JavaScript doesn’t execute code randomly. Every time it runs, it creates an Execution Context ⚡ Understanding this concept makes hoisting and closures much easier to master. 🔹 Two Main Phases: 1️⃣ Memory Creation Phase • Variables are stored as undefined • Functions are stored completely in memory 2️⃣ Code Execution Phase • Code runs line by line • Values get assigned 🔹 Example: var a = 10; function greet() { console.log("Hello"); } 👉 Memory Phase: a → undefined greet → full function 👉 Execution Phase: a → 10 Once you understand Execution Context, debugging becomes much easier and JavaScript starts making logical sense instead of feeling “magical”. Connect with me on LinkedIn: https://lnkd.in/dx7fPEsy #JavaScript #ExecutionContext #FrontendDeveloper #WebDevelopment #Programming #Coding #Developers #TechContent #LearningInPublic 🚀
To view or add a comment, sign in
-
-
It's 5:45 am & I am still looking at my dreams. Today[2/28/2026] is day 23 of learning javascript Today & tommorow i will learn are: 1. Difference between let, const & var 2. How to use the default parameter 3. Template string, Multiline string, Dynamic string 4. Arrow Function Syntax, params 5. Spread Operator, Array Max, Copy Arrays 6. Object & Array destructuring 7. Keys, Values, Entries, Delete, Seal, Freeze 8. Accessing Object Data: Nested Object, Optional Chaining 9. Looping Object 10. Primitive Type, Non Primitive Type 11. Null Vs Undefines 12. Truthy & Falsy Values 13. ==, === , implicit conversion 14. Block Scope, Global Scope, Simple Unders. of Hoisting 15. Closure 16. Callback Function & pass different function 17. Function Arguments, pass by ref. pass by value 18. Map, ForEach 19. Filter, Find, Reduce #letsconnect #programmer #frontenddeveloper #mernstakedeveloper #Coding
To view or add a comment, sign in
-
😂 𝗣𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗶𝗻 𝘁𝘄𝗼 𝗲𝗿𝗮𝘀, 𝘀𝗮𝗺𝗲 𝗽𝗿𝗼𝗯𝗹𝗲𝗺: 𝗼𝘃𝗲𝗿𝗰𝗼𝗺𝗽𝗹𝗶𝗰𝗮𝘁𝗶𝗻𝗴 𝘀𝗶𝗺𝗽𝗹𝗲 𝗹𝗼𝗴𝗶𝗰 2020: solve a basic odd/even check with a giant chain of if statements 😅 2026: wrap a tiny problem in an unnecessary abstraction / helper call 📦💀 Different style… same issue: using too much for something simple. Real lesson (and it matters) 👇 Good programming is not about writing more code. It’s not about using more libraries either. It’s about: ✅ knowing the simplest correct solution ✅ understanding built-in language features ✅ using libraries when they solve a real problem (not a 1-line one) ✅ keeping code readable, testable, and easy to maintain Libraries are powerful. 🛠️ But engineering judgment is knowing when not to add one. Sometimes the best code is: ◆ smaller ◆ boring ◆ obvious ◆ and done ✅ #Programming #SoftwareEngineering #DeveloperHumor #CleanCode #JavaScript #Coding #ProblemSolving #DeveloperMindset #WebDevelopment
To view or add a comment, sign in
-
More from this author
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