most developers don't know array destructuring doesn't create new variables. they think it does. it doesn't. the problem: destructuring assigns to names. those names point to the same values. reassigning one doesn't break the original. confusion happens when you destructure and expect immutability. the rule: destructuring extracts values into new variable names. it doesn't link them. reassignment creates new local bindings. original data stays untouched. this is actually good. it prevents accidental mutations. #javascript #typescript #webdevelopment #buildinpublic #reactjs
Destructuring in JavaScript: Assigns Names, Not New Variables
More Relevant Posts
-
Most developers still deep clone objects like this: JSON.parse(JSON.stringify(data)) It works. Until it doesn't. Dates become strings. Functions vanish. undefined disappears silently. Circular references throw an error. There's a native alternative that actually handles these cases — and most developers don't know it exists. One caveat: structuredClone() doesn't clone functions or class instances — it's designed for data, not behavior. But for 90% of real-world cases, that's exactly what you need. Available natively in all modern browsers and Node.js 17+ — no library required. Are you still using JSON tricks for deep cloning? 👇 #JavaScript #WebDevelopment #Frontend #JS #SoftwareEngineering
To view or add a comment, sign in
-
-
most developers don't know why their async code breaks. they blame promises. they blame async/await. they blame the API. but the real problem is this : code snippet ! always check before you render. async code creates a gap between "i requested data" and "i have data." that gap will break you if you don't account for it. #javascript #reactjs #typescript #webdevelopment #buildinpublic
To view or add a comment, sign in
-
-
most developers don't understand closures and it breaks their loops. classic problem: everyone uses let now so this fixes itself but the problem is still there, just hidden. here's why it happens: - when you use var > it's function-scoped not block-scoped. - by the time the timeout runs, the loop is done and i is 3. - all three callbacks reference the fix with let: let is block-scoped so each iteration gets its own i . but here's what you should actually know: - this isn't a JavaScript problem. this is a closure problem. - every function closes over the variables around it. - understanding that changes everything about how you debug async code, event listeners, callbacks. stop memorizing the fix. understand why it happens. #javascript #typescript #webdevelopment #buildinpublic #reactjs
To view or add a comment, sign in
-
-
🚀 JavaScript Event Loop: Your Async Superpower! 🌀 Confused how JS juggles multiple tasks on one single thread? 😵 Let's break it down visually! 1. Call Stack 📚: Runs your code line-by-line (sync stuff first!). 2. Web APIs 🌐: Handles async like setTimeout or fetch outside the stack. 3. Queues: • Microtask Queue ⚡ (Promises – VIP priority! Executes ASAP) • Callback Queue ⏳ (setTimeout – waits its turn) 4. Event Loop 🔄: Magic conductor! Checks empty stack → Microtasks → Callbacks. Pro Tip: Master this for smoother React hooks, Node servers, or any async magic! 💥 What’s your biggest Event Loop "aha" moment? Drop it below! 👇 #JavaScript #EventLoop #WebDev #ReactJS #NodeJS #Frontend #AsyncJS #CodingTips #Programming #DevCommunity #SoftwareEngineering #LearnToCode
To view or add a comment, sign in
-
-
Claude Code Tip😀 I told Claude Code that 𝗖𝗼𝗱𝗲𝘅 𝘄𝗶𝗹𝗹 𝗿𝗲𝘃𝗶𝗲𝘄 𝘁𝗵𝗲 𝗴𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝗱 𝗼𝘂𝘁𝗽𝘂𝘁. Now, Claude code generates better output all the time 😀 𝗣𝗿𝗼 𝘁𝗶𝗽: Add accountability pressure to your AI prompts. "Senior engineer will review this" works too. 👀 #javascript #reactjs #nextjs #webdevelopment #claudecode
To view or add a comment, sign in
-
Day 5 — Find Largest Number in an Array (JavaScript) Problem Write a function to find the largest number in an array. Example Input: [3, 7, 2, 9, 5] Output: 9 Approach Loop through the array and keep track of the maximum value. Code function findLargest(arr){ let max = arr[0] for(let i = 1; i < arr.length; i++){ if(arr[i] > max){ max = arr[i] } } return max } console.log(findLargest([3,7,2,9,5])) Alternative Approach function findLargest(arr){ return Math.max(...arr) } What I Learned How to track maximum value while iterating through an array. #javascript #frontenddeveloper #codingpractice #webdevelopment
To view or add a comment, sign in
-
-
"JavaScript is single-threaded… but still handles async tasks?" 🤯 This is where the Event Loop comes in 🔥 Let’s understand it simply 👇 🔹 JavaScript is single-threaded It can do one task at a time using the Call Stack. 🔹 So how does async work? Thanks to: - Web APIs 🌐 - Callback Queue 📥 - Event Loop 🔁 💻 Example: console.log("Start"); setTimeout(() => { console.log("Async Task"); }, 0); console.log("End"); 👉 Output: Start End Async Task 🔹 Why this happens? - "setTimeout" goes to Web APIs - Then moves to Callback Queue - Event Loop waits for Call Stack to be empty - Then executes it 🚀 Pro Tip: Even "setTimeout(..., 0)" is NOT immediate. 💬 Did this surprise you the first time you learned it? 😄 #javascript #webdevelopment #mern #coding #developers
To view or add a comment, sign in
-
🔥 JavaScript Devs — Why “Undefined” Causes So Many Real Bugs Hey devs 👋 One of the smallest values in JavaScript… Creates some of the biggest headaches 😅 👉 undefined often appears when: Missing API fields Wrong property names Unreturned functions Async race conditions 💥 Then suddenly: Cannot read property of undefined 💡 What helps: ✔ Optional chaining ?. ✔ Default values ?? ✔ Strong typing (TypeScript) ✔ Better API contracts ⚡ Senior insight: “Most runtime bugs start with assumptions.” Never assume data exists. What bug did undefined cause for you? #javascript #typescript #programmingtips #webdevelopment #frontenddeveloper #backenddeveloper #codingbestpractices #softwareengineering #jsbugs #cleanCode
To view or add a comment, sign in
-
-
We scanned 𝗥𝗲𝗮𝗰𝘁.𝗷𝘀. Used by millions of developers worldwide. 𝟭𝟰𝟯 𝗶𝘀𝘀𝘂𝗲𝘀. 81 of them critical. 🔴 Here's what shocked us: 🔴 XSS vulnerability - user uploaded files reflected without sanitization 🔴 Code injection via eval() - arbitrary code execution possible 🔴 Missing authentication on POST endpoints 🔴 Path traversal - attackers can overwrite system files 🔴 Secrets exposed to client via environment variables This is not some unknown side project. This is the framework your entire frontend probably runs on. We are not saying React is broken. We are saying - no codebase is perfect. Not even the ones you trust the most. That's exactly why code scanning exists. Not to blame. Not to scare. But to know. Because the earlier you find it, the cheaper it is to fix. Full report in first comment 👇 #ReactJS #JavaScript #WebSecurity #CodeReview #Relia #BuildInPublic #OpenSource #Developer
To view or add a comment, sign in
-
-
We scanned 𝗥𝗲𝗮𝗰𝘁.𝗷𝘀. Used by millions of developers worldwide. 𝟭𝟰𝟯 𝗶𝘀𝘀𝘂𝗲𝘀. 81 of them critical. 🔴 Here's what shocked us: 🔴 XSS vulnerability - user uploaded files reflected without sanitization 🔴 Code injection via eval() - arbitrary code execution possible 🔴 Missing authentication on POST endpoints 🔴 Path traversal - attackers can overwrite system files 🔴 Secrets exposed to client via environment variables This is not some unknown side project. This is the framework your entire frontend probably runs on. We are not saying React is broken. We are saying - no codebase is perfect. Not even the ones you trust the most. That's exactly why code scanning exists. Not to blame. Not to scare. But to know. Because the earlier you find it, the cheaper it is to fix. Full report in first comment 👇 #ReactJS #JavaScript #WebSecurity #CodeReview #Relia #BuildInPublic #OpenSource #Developer
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
the confusion isn't about destructuring mechanics, it's that developers mix reference types with primitives. destructuring an object gives you the same reference, not a copy. reassigning a primitive breaks the link, but mutating an object property doesn't. the immutability expectation fails because they're not destructuring immutably in the first place.