The Surprising History of null in JavaScript

Today I Learned: The Surprising History of null in JavaScript Did you know that the concept of null has been in existence for nearly 60 years and is often called a “billion-dollar mistake"? Time ⏰ Where it started In 1965, the computer scientist Sir Tony Hoare introduced the concept of a null reference in ALGOL W to denote the absence of a value. Although useful, it eventually caused an immeasurable amount of bugs, crashes, and security problems — which later motivated Hoare to say: “I call it my billion-dollar mistake.” How it reached JavaScript JavaScript inherited null from Java when it was created by Brendan Eich back in 1995. But it also introduced another value: undefined. Since then developers have had to deal with both: null // absence of intention undefined // not assigned value Fun fact: typeof null === "object" // true In fact, this is a long-standing bug from the earliest JavaScript implementation, kept for compatibility. A good reminder that small design decisions can shape the industry for decades. ⚙️ Modern JavaScript now gives us safer tools to handle missing values: user?.profile // optional chaining value ?? "default" // nullish coalescing Takeaway null was born with good intentions but also taught us a powerful lesson in language design and defensive programming. Understanding its history helps us write cleaner and safer JavaScript. #JavaScript #WebDevelopment #TIL #ProgrammingHistory #SoftwareEngineering #Developers #LearningEveryday # 10000 Coders # Sudheer Velpula

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories