⚡ Developer Brain Teaser – Only Experienced Developers Notice This What will be the output of this JavaScript code? 👇 console.log(typeof null); 🧠 Options A️⃣ "null" B️⃣ "object" C️⃣ "undefined" D️⃣ "number" 👇 Comment your answer before scrolling further. . . . ✅ Correct Answer: B️⃣ "object" 💡 Explanation In JavaScript: typeof null returns: "object" This is actually considered a historical bug in JavaScript that has existed since the first version of the language. Why? Internally, JavaScript represents values using type tags, and null was incorrectly tagged as an object. Because fixing it would break millions of existing applications, it has never been changed. 📌 Learning Point Even senior developers get surprised by JavaScript quirks. Understanding these edge cases helps during debugging, interviews, and writing reliable code. 💬 Did you know this already? Comment “Yes” or “Learned something new today” 👇 #JavaScript #FrontendDevelopment #Angular #CodingChallenge #Developers #TechLearning #SoftwareEngineering
JavaScript typeof null returns 'object'
More Relevant Posts
-
JavaScript developers must understand how to work with APIs effectively. One of the cleanest ways to handle asynchronous data is by using Async/Await with the Fetch API. In the example, the code fetches user data from an API and processes it asynchronously. Key concepts demonstrated: • Using async functions to handle asynchronous operations • Fetching data from an external API • Converting response into JSON format • Iterating through the received data using forEach • Handling errors using try...catch This pattern makes asynchronous JavaScript easier to read and maintain compared to traditional Promise chains. Understanding this concept is essential when building modern web applications, especially when working with REST APIs. What do you prefer for handling async operations in JavaScript? Comment it in the inbox 📥 Async/Await or Promises? 👨💻 #JavaScript #WebDevelopment #AsyncAwait #FrontendDevelopment #Coding #Programming #Developers
To view or add a comment, sign in
-
-
JavaScript Array Methods you CAN’T ignore as a developer 🚀 If you’re still looping everything manually… you’re doing it wrong. Here are must-know array methods every dev should master: 🔥 filter() → Get matching data 🔥 map() → Transform data 🔥 find() → First match 🔥 some() → At least one condition 🔥 every() → All conditions must pass 🔥 includes() → Check existence 🔥 findIndex() → Get index 🔥 push()/pop() → Modify array 💡 Pro Tip: Use `map()` + `filter()` heavily in React for clean & scalable code. Master these = cleaner code + better interview performance 💯 💾 Save this for later 💬 Which one do you use the most? #javascript #webdevelopment #reactjs #codingtips #frontend #backend #programming
To view or add a comment, sign in
-
-
💡 Does JavaScript Support Automatic Type Conversion? Yes, it does — and it’s called Type Coercion. JavaScript is a loosely typed language, which means it can automatically convert one data type into another when performing operations. 🧠 What’s happening here? ✔️ + with a string → converts everything to string ✔️ -, *, / → converts values to numbers ✔️ true → 1 and false → 0 ⚠️ Be careful: Automatic type conversion can sometimes lead to unexpected results, which may cause bugs in your application. That’s why developers often use explicit conversion 🚀 In simple terms: JavaScript can automatically change data types when needed, but understanding this behavior helps you write more predictable and bug-free code. #JavaScript #WebDevelopment #Programming #Coding #SoftwareDevelopment #Developers #LearnJavaScript #TechLearning #CodingJourney #FrontendDevelopment #TechCommunity
To view or add a comment, sign in
-
-
💡 Interview Question: Understanding Data Types in JavaScript Recently came across an interesting question that tests your fundamental 👇 let a = ''; let b = false; let c = 0; let d = null; let e; let f = {}; let g = []; if (!a) console.log('1') // similarly check for b, c, d, e, f, g 👉 Question: What will be printed in the console for each variable? 🧠 Concept Tested: Truthy vs Falsy values in JavaScript 📌 Falsy values in JS: '' (empty string) false 0 null undefined NaN 📌 Truthy values: {} (empty object) [] (empty array) ✅ Output: 1 2 3 4 5 (Only for a, b, c, d, e → because they are falsy) 🚫 Nothing will be printed for: f = {} g = [] (because they are truthy) 🎯 Key Takeaway: Even empty objects and arrays are considered truthy in JavaScript — a common interview trap! #JavaScript #FrontendDevelopment #WebDevelopment #CodingInterview #InterviewQuestions #Programming #Developers #TechTips #LearnToCode
To view or add a comment, sign in
-
Shallow Copy vs Deep Copy While working on complex state management in JavaScript / TypeScript I revisited a fundamental concept that often causes subtle bugs A shallow copy only copies the first level. Nested objects still share the same reference. const obj = { user: { name: "Nazim" } }; const copy = { ...obj }; copy.user.name = "Changed"; console.log(obj.user.name); // "Changed" 👉 Even though we created a “copy”, both objects are still linked internally. On the other hand, a deep copy creates a completely independent clone, including all nested structures. const deepCopy = structuredClone(obj); deepCopy.user.name = "Changed"; console.log(obj.user.name); // "Nazim" Applications: • Prevents unintended state mutation in React / Next.js • Ensures predictable behavior in state management (Redux, Zustand) • Avoids hard-to-debug side effects in large-scale applications
To view or add a comment, sign in
-
📒 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 𝐡𝐚𝐬 𝐚 𝐜𝐥𝐞𝐚𝐧𝐞𝐫 𝐫𝐮𝐧𝐧𝐢𝐧𝐠 𝐢𝐧 𝐭𝐡𝐞 𝐛𝐚𝐜𝐤𝐠𝐫𝐨𝐮𝐧𝐝… 𝐚𝐧𝐝 𝐦𝐨𝐬𝐭 𝐝𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫𝐬 𝐢𝐠𝐧𝐨𝐫𝐞 𝐢𝐭. 𝑌𝑒𝑠, 𝐼’𝑚 𝑡𝑎𝑙𝑘𝑖𝑛𝑔 𝑎𝑏𝑜𝑢𝑡 𝐺𝑎𝑟𝑏𝑎𝑔𝑒 𝐶𝑜𝑙𝑙𝑒𝑐𝑡𝑖𝑜𝑛 (𝐺𝐶) ♻️ Every time you create: ✅ objects ✅ arrays ✅ functions 𝐽𝑎𝑣𝑎𝑆𝑐𝑟𝑖𝑝𝑡 𝑎𝑙𝑙𝑜𝑐𝑎𝑡𝑒𝑠 𝑚𝑒𝑚𝑜𝑟𝑦. 𝐵𝑢𝑡 𝑡ℎ𝑒 𝑟𝑒𝑎𝑙 𝑞𝑢𝑒𝑠𝑡𝑖𝑜𝑛 𝑖𝑠… When does JS free that memory? ➡️ Only when the value becomes unreachable. 🔥 Reachable = Alive If something can be accessed from: 1️⃣ global variables 2️⃣ current function variables 3️⃣ call stack …it stays in memory. Example: 𝗹𝗲𝘁 𝘂𝘀𝗲𝗿 = { 𝗻𝗮𝗺𝗲: "𝗝𝗼𝗵𝗻" }; 𝘂𝘀𝗲𝗿 = 𝗻𝘂𝗹𝗹; Now no one can access it → GC removes it. ⚡ 𝐵𝑖𝑔𝑔𝑒𝑠𝑡 𝑚𝑖𝑠𝑐𝑜𝑛𝑐𝑒𝑝𝑡𝑖𝑜𝑛: “Objects are deleted when they have no references.” Not exactly. Because two objects can reference each other and STILL get deleted. 📌 If the main root reference is gone, the whole connected group becomes an unreachable island → GC clears everything. 🚀 𝑊ℎ𝑦 𝑠ℎ𝑜𝑢𝑙𝑑 𝑦𝑜𝑢 𝑐𝑎𝑟𝑒? Because this is how memory leaks happen: ❌ event listeners not removed ❌ unused variables still holding references ❌ large objects stored unnecessarily Result: 🐢 slow apps 💥 crashes 📉 poor performance 💡 Simple rule: If you don’t need it → remove the reference. Because JavaScript will clean it… only after you let go. #JavaScript #WebDevelopment #Frontend #ReactJS #Programming #Coding #SoftwareEngineering #Tech #Learning #interview
To view or add a comment, sign in
-
🚀 Hello Everyone ✋ Practicing JavaScript Array Methods 💻 Today I worked on some important JavaScript array operations that are super useful for real-world development. Here’s a quick summary of what I explored 👇 🔹 filter() method Extracted even numbers from an array Separated positive and negative numbers Filtered strings based on length Retrieved names starting with a specific letter Removed falsy values like 0, null, undefined, and empty strings 🔹 Sorting & Reversing Used sort() to arrange elements Used reverse() to flip the order 🔹 Array Manipulation Methods pop() → Remove last element push() → Add element at the end shift() → Remove first element unshift() → Add element at the beginning 💡 Key Learning: Understanding these methods makes data handling much easier and improves code readability and efficiency. 📌 Next step: Deep dive into map() and forEach() for transformations and iterations. #JavaScript #WebDevelopment #Coding #Learning #Frontend #100DaysOfCode
To view or add a comment, sign in
-
🧪 Memory Leak Laboratory an open-source tool for JavaScript/TypeScript developers One of the most common reasons a Node.js app slows down over time with no obvious cause is a memory leak hiding inside the code we write every day. A friend and I built js-leak-lab as a hands-on learning tool, not just another article you read and imagine your way through. What you can do in this lab 🔬 • Simulate 20 memory leak patterns unbounded arrays, closures holding references longer than they should, event listeners that never get removed, and more • Toggle leaks on and off instantly and watch the heap spike in real time • Compare Bad Code vs Good Code side-by-side, with both actually runnable • Monitor heap, RSS, and external memory through live gauges and charts updated via WebSocket ⚙️ Stack: Bun + Bun.serve(), Tailwind CSS, Chart.js, Prism.js no frontend build step, open it and it just works 🐳 Docker-ready with memory limit support since this lab simulates real leaks, setting a RAM cap is strongly recommended Built for developers who want to understand how memory leaks actually happen and how to fix them correctly before production figures it out for you. 🔗 GitHub: https://lnkd.in/gRTGUq2C 🌐 Demo: https://lnkd.in/gtjBDp9a #JavaScript #TypeScript #OpenSource #WebDevelopment #NodeJS #MemoryLeak #Bun #DevTools
To view or add a comment, sign in
-
-
Stop Confusing Threading with Timing in JavaScript! 🧵⏱️ If you are mastering the MERN stack, understanding how the JavaScript engine actually executes your code is not just optional it’s critical for building high-performance applications that scale. The problem is, most developers confuse Single-Threaded with Synchronous. They aren't the same. I put together this mental model to keep them straight for your next technical interview. 👇 📌 Save this for future reference! 1. THREADS (Who is doing the work?) This is about resources. 🔹Single-Threaded: Exactly ONE worker. (This is JavaScript's main thread). 🔹Multi-Threaded: Multiple workers cooking at the exact same time. (Java, C++). ⏱️ 2. TIMING (When does the work get done?) This is about execution order. 🔹Synchronous: The worker puts water on the stove and stares at it until it boils. They cannot do anything else until that task is 100% finished. (Blocking). 🔹Asynchronous: The worker puts water on the stove, sets a timer, and walks away to chop onions. The worker is always moving. (Non-blocking). 💡 A moment of clarity Out of the box, JavaScript is Single-Threaded AND Synchronous. It has one worker, and that worker does things one by one. So how do we handle heavy tasks? By using the Event Loop 🔄 to change the Timing from Synchronous to Asynchronous. JavaScript hands off heavy tasks (like database fetch requests or setTimeout) to the Browser/Node.js background APIs. The single main thread stays free to keep the UI snappy and responsive, and the Event Loop pushes the finished data back to the thread when it's ready! #JavaScript #WebDevelopment #MERNstack #BackendDevelopment #FrontendDevelopment #TechnicalInterviews #EventLoop #CodingCheatSheet #ProofOfWork #LearningInPublic
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