💡 𝗦𝗺𝗮𝗹𝗹 𝗠𝗶𝘀𝘁𝗮𝗸𝗲, 𝗕𝗶𝗴 𝗟𝗲𝘀𝘀𝗼𝗻 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁! Today, I hit an error that said: '𝘥𝘦𝘭𝘦𝘵𝘦' 𝘤𝘢𝘯𝘯𝘰𝘵 𝘣𝘦 𝘤𝘢𝘭𝘭𝘦𝘥 𝘰𝘯 𝘢𝘯 𝘪𝘥𝘦𝘯𝘵𝘪𝘧𝘪𝘦𝘳 𝘪𝘯 𝘴𝘵𝘳𝘪𝘤𝘵 𝘮𝘰𝘥𝘦. At first glance, it looked confusing — but it turned out to be a great reminder about how JavaScript actually works under the hood. In JavaScript, the 𝘥𝘦𝘭𝘦𝘵𝘦 operator is meant to remove object properties, not variables. ✅ delete obj.key — works perfectly ❌ delete variableName — throws an error (especially in strict mode) 𝗪𝗵𝘆? Because variables declared with let, const, or var are not object properties — they belong to the current scope. Trying to “delete” them breaks the language rules. 𝗟𝗲𝘀𝘀𝗼𝗻 𝗹𝗲𝗮𝗿𝗻𝗲𝗱: If you just want to clear a variable, use variable = null; and let JavaScript’s garbage collector do the rest. Sometimes the smallest syntax errors teach the biggest fundamentals! 🚀 #JavaScript #TypeScript #WebDevelopment #CodingTips #LearningEveryday
Learned a valuable lesson about JavaScript's delete operator in strict mode.
More Relevant Posts
-
🌀 𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗣𝗿𝗼𝘅𝗶𝗲𝘀 — 𝗜𝗻𝘁𝗲𝗿𝗰𝗲𝗽𝘁, 𝗖𝗼𝗻𝘁𝗿𝗼𝗹 & 𝗣𝗼𝘄𝗲𝗿 𝗨𝗽 𝗬𝗼𝘂𝗿 𝗢𝗯𝗷𝗲𝗰𝘁𝘀 Wrappers, traps, handlers — the native Proxy object in JavaScript gives you 𝗺𝗲𝘁𝗮-𝗰𝗼𝗻𝘁𝗿𝗼𝗹 over how your objects behave. Want to intercept property access, validate assignments, or log operations? Proxies unlock that power. In this post I break down: ✅ What Proxy objects really do (the target + handler + traps model) ✅ How traps like `get`, `set`, `apply`, `construct` let you intercept reads, writes, function calls and constructor calls ✅ Real-world use cases: validation, access control, logging, lazy initialization, smart defaults 👉 Read here: https://lnkd.in/d2z-7z6w Stay curious. Code smarter. 🧠 #JavaScript #WebDevelopment #Proxies #Metaprogramming #CodingTips
To view or add a comment, sign in
-
🚀 Day 3 of My 30 Days of JavaScript Challenge 🧩 Problem: Implement expect() Function (LeetCode #2704) Write a function expect that helps developers test their code. It takes a value val and returns an object with two methods: toBe(val) → returns true if both values are strictly equal (===), else throws "Not Equal" notToBe(val) → returns true if both values are not strictly equal (!==), else throws "Equal" 💻 Language: JavaScript ❓ Question: https://lnkd.in/eJcRKeme 💡 Solution: https://lnkd.in/eZY9mYHN 🧠 Concepts Used: Higher-order functions (function returning object with functions) Error handling using throw new Error() Strict equality (===) in JavaScript 📚 Takeaway: This exercise reinforces function design, object methods, and error handling — the foundation for building custom testing utilities and debugging tools in JavaScript. #Day3 #JavaScript #LeetCode #30DaysOfCode #CodingChallenge #WebDevelopment #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
🔥 Master JavaScript String Methods in Minutes! Strings are everywhere — from user input to API responses. Knowing how to manipulate them efficiently can save you tons of time. Here’s a handy visual cheatsheet of the most used String methods: ✨ .charAt() → grab a character ✨ .concat() → merge strings ✨ .startsWith() / .endsWith() → quick checks ✨ .includes() → search inside strings ✨ .padStart() / .padEnd() → formatting made easy ✨ .repeat() → repeat content ✨ .replace() → swap text ✨ .split() → break into arrays ✨ .toUpperCase() / .toLowerCase() → change casing ✨ .trim() → clean extra spaces Save this for later 🔖 and never get stuck Googling again. 💬 What’s your most used String method in real projects? hashtag#JavaScript hashtag#WebDevelopment hashtag#Frontend hashtag#Coding hashtag#SoftwareEngineering hashtag#100DaysOfCode hashtag#JavaScriptTips
To view or add a comment, sign in
-
-
🧩 Undefined vs Null 🤔 ✨ When there’s no existence, it’s Undefined, whereas emptiness exists by choice, it’s Null. 🔹 undefined → When a variable is declared but not assigned by the user, JavaScript itself assigns the value undefined by default. let a; console.log(a); // undefined 🧠 It means: “No value exists yet — JavaScript couldn’t find one.” 🔹 null → When a variable is explicitly assigned by the user to represent emptiness, it holds the value null. let b = null; console.log(b); // null 💡 It means: “The developer intentionally set this to nothing.” ⚙️ Type check curiosity typeof null; // "object" ❗ (a known JavaScript bug) typeof undefined; // "undefined" 🚫 Falsy values Both are falsy during condition checks 👇 if (!undefined && !null) console.log('Falsy values!'); 🎯 In short: 🟠 undefined → Not assigned by the user → JavaScript assigns it automatically. 🟣 null → Explicitly assigned by the user → JavaScript doesn’t assign it. 🔖 Hashtags #JavaScript #WebDevelopment #Frontend #CodingTips #LearnToCode #JSBasics #WebDevCommunity #JavaScriptTips #CodeNewbie #DeveloperInsights
To view or add a comment, sign in
-
🚀 Day 88/90 – #90DaysOfJavaScript Topic covered: Today I explored how JavaScript handles String & Number primitives vs String & Number objects.s ✅ String Primitive vs String Object 👉 "Hello" → primitive (lightweight, fast) 👉 new String("Hello") → wrapper object (rarely needed) 👉 JS temporarily wraps primitives to access methods like .length, .slice(), .repeat() ✅ Number Constructor 👉 new Number("34") → Number object (typeof → "object") 👉 Number("34") → converts to number (typeof → "number") ✅ Type Conversion Rules 👉 Number("45") → ✅ 45 👉 Number("abc") → ❌ NaN 👉 Number(true) → ✅ 1 👉 Number(null) → ✅ 0 👉 Number(undefined) → ❌ NaN 👉 Arrays & objects behave differently in numeric conversion ✅ Key Rule 👉 Always use Number(value) for conversion ❌ Avoid new Number() unless absolutely necessary 🧠 Takeaway: JS primitives are faster & efficient — wrapper objects only exist to give methods to primitives. Prefer primitives for real-world use. 🛠️ Access my GitHub repo for all code and explanations: 🔗 https://lnkd.in/e347pqH7 Let’s learn together! Follow my journey to #MasterJavaScript in 90 days! 🔁 Like, 💬 comment, and 🔗 share if you're learning too. #JavaScript #WebDevelopment #CodingChallenge #Frontend #JavaScriptNotes #MasteringJavaScript #GitHub #LearnInPublic
To view or add a comment, sign in
-
🗓️ Day 12 of JavaScript LeetCode Challenge Problem: 2619. Array Prototype Last Approach: In this problem, I enhanced the Array prototype to include a custom method last() that returns the last element of an array. If the array is empty, it returns -1. I used the this keyword in JavaScript, which refers to the current object on which the function is being called. In global scope, this refers to the window object. Inside a function or method, the value of this depends on how the function is called. Here, since the last() method is called on an array, this refers to that specific array instance. Using this reference, we can easily access its length and return the last element.
To view or add a comment, sign in
-
-
🌀 𝗧𝗵𝗲 𝗦𝘂𝗯𝘁𝗹𝗲 𝗣𝗼𝘄𝗲𝗿 𝗼𝗳 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗦𝘆𝗺𝗯𝗼𝗹𝘀 In this article I explore how the native `Symbol` type in JavaScript gives you a 𝘂𝗻𝗶𝗾𝘂𝗲, 𝗽𝗿𝗶𝘃𝗮𝘁𝗲, 𝗮𝗻𝗱 𝗵𝗶𝗱𝗱𝗲𝗻 𝗸𝗲𝘆-𝘁𝗼𝗼𝗹𝗯𝗼𝘅 — useful when you want to extend objects, avoid collisions, or build internal APIs that aren’t visible to external code (or yourself after a few months). Here’s what you’ll take away: ✅ What `Symbol()` really is — a primitive value guaranteed unique, not coerced into strings or numbers. ✅ How symbol-keyed properties let you 𝗲𝘅𝘁𝗲𝗻𝗱 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 𝘀𝗮𝗳𝗲𝗹𝘆, add hidden members, or decorate libraries without accidental overwrites. ✅ Why the built-in “well-known symbols” (like `Symbol.iterator`, `Symbol.toPrimitive`, etc.) unlock advanced behaviors and let you hook into JavaScript’s internal protocols. 👉 𝗥𝗲𝗮𝗱 𝗵𝗲𝗿𝗲: https://lnkd.in/dBNG9ENQ Stay curious. Use symbols smartly. 🧠 #JavaScript #WebDevelopment #Symbols #Metaprogramming #CodingTips
To view or add a comment, sign in
-
Ran into a curious JavaScript quirk today while working on a flatten() function. Encountered an array with [null, true, undefined] where typeof null === "object" led to unexpected recursion due to null behaving like an object. The quick fix: if (typeof val === "object" && val), but the optimal solution? Array.isArray(val). Takeaway: JavaScript's nuances remind us that not everything resembling an object should be handled as one. And yes, null remains a humble reminder for all developers. JavaScript, always full of surprises! 🤓
To view or add a comment, sign in
-
🚀 Day 11 of My 30 Days of JavaScript Journey ✅ Challenge: Memoize (LeetCode #2623) The task was to create a memoize(fn) function that caches results so that repeated calls with the same inputs return instantly from cache — without re-executing the original function. This helps improve performance when dealing with expensive computations like fibonacci or factorial, and even simple operations like sum when called repeatedly. 💻 Language Used: JavaScript ❓ Problem Link: https://lnkd.in/gnHmbPih 💡 Solution: https://lnkd.in/gGJZjYY9 🧠 Concept Highlighted: Memoization is a powerful optimization technique that uses caching to avoid repeating calculations. It strengthens understanding of closures, function arguments handling, and performance-oriented JavaScript. #JavaScript #LeetCode #30DaysOfCode #CodingChallenge #WebDevelopment #FrontendDevelopment #Memoization #PerformanceOptimization #LearningEveryday #ProblemSolving
To view or add a comment, sign in
-
🚀 JavaScript Quick Tip: Type Coercion Made Simple! Have you ever wondered why: "1" + 2 // gives "12" "1" - 2 // gives -1 🤔 Let’s decode it 👇 JavaScript automatically converts values when needed — this is called Type Coercion. Here’s the simple rule to remember: 🧠 + → tries to make things strings (joins values together) -, *, / → try to make things numbers (do math operations) 💡 Pro Tip: Always be clear about data types — it’ll save you from some tricky JavaScript bugs! #javascript #webdevelopment #codingtips #typecoercion #frontend
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