🤔 Why `typeof null` == "object"? typeof null Anomaly (Concise Summary) The result typeof null === "object" is a historical anomaly stemming from an implementation flaw in the original 1995 JavaScript engine. 1️⃣ Origin: The internal NULL pointer representation for null accidentally shared the same type tag (000) used for objects. 2️⃣ Permanence: This bug was intentionally maintained in the ECMAScript specification to ensure backward compatibility and avoid breaking legacy code. Best Practice: Always use value === null for accurate null checks. #JavaScript #WebDevelopment #Programming #CodingTips #SoftwareEngineering #TechFacts #JavaScriptTips
Why typeof null is "object" in JavaScript
More Relevant Posts
-
The event loop (#3) has personally cost me more debugging hours than I'd like to admit in 2025. These 7 JavaScript gotchas don't throw errors. They create silent, hard-to-spot bugs that slip into production – even from senior and staff engineers. I've fallen for every single one. Swipe through → then check the last slide to share yours. 🔖 Save this now (your future debug sessions will thank you) #JavaScript #JavaScriptGotchas #Coding
To view or add a comment, sign in
-
T, my elegant, minimalist language that transpiles to JavaScript, does away with the weird old '&&' and '||' logical operator convention, and replaces them with '&' and '|'. If you REALLY need bit-wise operations (i.e. for the 3 cases in a lifetime where you do bit manipulation in a high-level language), T has a set of explicitly prefixed 'bit' operations for that. Less confusion, less typing, more logic! #t #javascript #compiler #programminglanguage #languagedesign #code
To view or add a comment, sign in
-
-
Give eyes to your agents 👀🕵🏼♀️ Given the complexity of building an entire JavaScript runtime, I´ve had to come up with a few tricks to make this work. I have built my own Agent-friendly profiler. And now I´m going full tracability for the execution runtime itself. Originally this all started as an AST walker, evaluating nodes recursively. Now this is becoming more of a byte-code compiler. and as such, I can now both print both the raw code itself. And I can print each executed instruction, and as such, we can see exactly what is going on inside a loop, or if-statements etc. maybe maybe, this will end up as an IL code compiler for JS :-D
To view or add a comment, sign in
-
-
This JavaScript comparison looks correct — but it fails. If a variable already holds a string, using JSON.stringify() on it will add quotes, changing the value and breaking equality checks. Small misunderstandings like this create real bugs in production code. Strong fundamentals matter more than memorizing APIs. #JavaScript #WebDevelopment #Programming #CodingTips #SoftwareEngineering #TechLearning
To view or add a comment, sign in
-
𝗘𝘃𝗲𝗿 𝘀𝗲𝗲𝗻 𝘁𝗵𝗶𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁? 𝚌𝚘𝚗𝚜𝚘𝚕𝚎.𝚕𝚘𝚐([𝟷,𝟸,𝟹]+[𝟺,𝟻,𝟼]) The output is: "𝟭,𝟮,𝟯𝟰,𝟱,𝟲" Why? Because the + operator triggers type 𝙘𝙤𝙚𝙧𝙘𝙞𝙤𝙣. Both arrays are converted to strings ("1,2,3" and "4,5,6") before concatenation. This is a great reminder that: JavaScript is flexible, but that flexibility can be surprising Understanding coercion rules helps prevent subtle bugs Clear intent matters use methods like concat() or the spread operator for arrays Small details like this separate writing code that works from writing code that’s reliable. #JavaScript #WebDevelopment #SoftwareEngineering #ProgrammingTips #CleanCode
To view or add a comment, sign in
-
-
The secret behind JavaScript's non-blocking nature. 🧠 The Event Loop is a fundamental concept that trips many developers up. It acts as the bridge between synchronous operations and asynchronous callbacks. Here is the basic flow: 1️⃣ All synchronous code is executed immediately in the Call Stack. 2️⃣ Asynchronous operations (like setTimeout or API calls) are offloaded to Web APIs. 3️⃣ When an async operation finishes, its callback is placed in the Callback Queue. 4️⃣ The Event Loop waits until the Call Stack is completely empty, then pushes the first task from the Queue into the Stack to run. Mastering this flow is crucial for debugging complex async behaviors! #JavaScript #WebDev #Programming #JSConcepts #AsyncProgramming #DeveloperTips #LearnToCode
To view or add a comment, sign in
-
-
The new transpiler to compile the latest and final version of my language, T, to JavaScript, is now almost complete (pending some production code testing). It borrows the best bits from CoffeeScript and enhances on some of the concepts, adds preprocessor macros, a powerful omnipotent `each` loop, and a bit of syntactic sugar and elegance (not arrogance 😄). What I found slightly unsettling: The entire compiler (itself written in the previous dialect of T) is only ~ 3200 lines 🤯 Am I doing something wrong? 🥴 #efficiency #programming #softwaredevelopment #t #t3 #javascript
To view or add a comment, sign in
-
-
The compiler for T, my language that transpiles to JavaScript, works by directly transforming the input tokens to the output tokens (with a few surgical exceptions). No abstract intermediate representations like AST. This means that it's insanely small, fast, and memory-efficient, but also a bit gnarly when it comes to handling edge-cases and finding subtle compilation bugs, especially since T's syntax is very concise and freeform. But on the flipside, it only took a few weeks full-time to develop and fully test. It's always a tradeoff! #compilers #compiler #t #javascript #softwaredevelopment #cs #computerscience
To view or add a comment, sign in
-
-
🔥 Day 26 of #30DaysOfJavaScript #LeetCode 2705: Compact Object Today I worked on a really interesting problem — building a recursive function that removes all falsy values from an object or array, including deeply nested ones. Falsy values include: false, 0, "", null, undefined, NaN The twist? 👉 Arrays are also treated as objects 👉 And we must compact every nested level 👉 Without using any built-in magic ✨ 🧠 Key Learnings ✅ Recursion is perfect for tree-like structures ✅ Array.isArray() helps treat arrays differently ✅ Boolean(value) is a clean way to test truthiness ✅ JSON constraints simplify the problem #JavaScript #LeetCode #30DaysOfCode #WebDevelopment #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Another day, another classic JavaScript "gotcha"! This snippet is a perfect quick test of your understanding of the Event Loop, specifically how JavaScript handles asynchronous operations. The key concepts here: 1️⃣ Synchronous code always runs first on the Call Stack. 2️⃣ Microtasks (like Promise callbacks) have priority and are executed immediately after the synchronous code finishes. 3️⃣ Macrotasks (like setTimeout) are executed only after the Call Stack and the Microtask Queue are completely empty—even if the delay is set to 0ms. 👇 Drop the correct order of the console logs in the comments below! Let's see who gets it right on the first try. #JavaScript #WebDevelopment #CodingChallenge #EventLoop #FrontEndDeveloper #Programming
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