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
The Surprising History of null in JavaScript
More Relevant Posts
-
JavaScript Deep Dive: The Story Behind null Today, I explored the origins of one of JavaScript’s quirkiest features — null. It turns out this little value has a surprising history! 🔹 Where it Began: JavaScript was created in 1995 by Brendan Eich in just 10 days. Since it was inspired by Java, null was included to represent the intentional absence of any object — just like in Java. 🔹 The Famous Bug: Ever wondered why this happens? typeof null // "object" This result is actually due to an early implementation bug. null was given the same type tag as objects — and fixing it would have broken lots of existing code. So it stayed. 😅 🔹 null vs undefined: JavaScript defines two empty values: null: Intentionally empty (set by programmers) undefined: Automatically assigned by JavaScript for missing or uninitialized values This distinction has confused developers for decades! 🔹 Standardized in ECMAScript: Both null and undefined were formalized in the first ECMAScript standard (1997), cementing their roles in the language. 💡 Takeaway: JavaScript's null is a great example of how early design decisions — even mistakes — can shape a language's future. Knowing its history helps us write code with more clarity and intention. Let’s keep learning the story behind the code! 🎯 #JavaScript #LearningInPublic #WebDevelopment #HistoryOfJS #Programming #10000Coders #CodeNewbie
To view or add a comment, sign in
-
-
🚀 JavaScript Revision Series — Day 3 Today’s revision was all about Operators in JavaScript — the tools that let us do everything from math to logic in our programs! 💻✨ 🟢 Operators Covered: Arithmetic: + - * / % Assignment: =, +=, -=, *= Logical: &&, ||, ! Ternary Operator: condition ? true : false 😄 Fun JS Moment: Remember, 5 + "1" = "51" But 5 - "1" = 4 JS loves to play tricks with operators 😅 --- 🔗 Daily Practice Repo: https://lnkd.in/ejQk84Zg Step by step, one operator at a time — building solid JS foundations! 🚀 #JavaScript #JavaScriptBasics #LearningJourney #WebDevelopment #FrontendDevelopment #CodingJourney #MERNStack #ConsistencyIsKey #SMIT #DeveloperCommunity #Saylani
To view or add a comment, sign in
-
-
Today’s Tiny JavaScript Project I wrote a simple “Fortune Teller” script in JavaScript — it picks a random fortune each time you run it! let fortune1 = "Your cat will look very cuddly today."; let fortune2 = "The weather will be nice tomorrow."; let fortune3 = "Be cautious of your new neighbors."; let fortune4 = "You will find a new hobby soon."; let fortune5 = "It would be wise to avoid the color red today."; let randomNumber = Math.floor(Math.random() * 5) + 1; let selectedFortune = randomNumber; if (randomNumber === 1) selectedFortune = fortune1; else if (randomNumber === 2) selectedFortune = fortune2; else if (randomNumber === 3) selectedFortune = fortune3; else if (randomNumber === 4) selectedFortune = fortune4; else if (randomNumber === 5) selectedFortune = fortune5; console.log(selectedFortune); 🧠 It’s a small project, but a fun way to practice: Random number generation Conditional logic Console output What fortune did you get when you ran it? 👀 #JavaScript #Coding #WebDevelopment #100DaysOfCode #LearnToCode
To view or add a comment, sign in
-
JavaScript taught me something cool today 🤔 You know how we write classes in JavaScript? Turns out, JS doesn't actually have "real" classes like Java or C++. It's a Prototype-based language wearing a class costume! ✨ ➡️When we write this: class Person { constructor(name) { this.name = name; } greet() { return `Hello, I'm ${this.name}`; } } ➡️ JavaScript actually does this: function Person(name) { this.name = name; } Person.prototype.greet = function() { return `Hello, I'm ${this.name}`; } 🔺 Same result, different reality! The class syntax is just syntactic sugar to make it look familiar. Under the hood, everything still runs on Prototypes, implementing Inheritance, Encapsulation, Abstraction and Polymorphism in its own unique way. 📌 Understanding this helped me: • Finally get why this acts weird sometimes • Debug inheritance issues way faster • Realize methods live on the prototype (memory efficient!) 🖊️ Anyone else had this "wait, what?" moment with JavaScript? 😅 #JavaScript #WebDevelopment #LearningToCode
To view or add a comment, sign in
-
👉✅ “Setting a one-week goal to revise JavaScript again.” 💻Topic-1. JavaScript Constructor Function Hey everyone, 👋 Today, let’s talk about an interesting JavaScript topic — the Constructor Function. This is a special type of function that helps us create multiple similar objects without writing the same code again and again! 🔁 🧠 Key points to understand: The name of a constructor function always starts with a capital letter. We use the new keyword when creating an object. It automatically returns a new object. Through this concept, we can explore the basics of Object-Oriented Programming (OOP) in JavaScript — including concepts like inheritance and encapsulation. 🚀 If you’re learning JavaScript, understanding constructor functions is a must-have skill — it makes your code cleaner, reusable, and more efficient! #JavaScript #WebDevelopment #CodingTips #ConstructorFunction #FrontendDevelopment #LearningEveryday
To view or add a comment, sign in
-
-
Javascript tries to execute the commands without raising concern so programmer should be careful ( #sujaiPost54 ) That’s one of the core characteristics of JavaScript: it’s a forgiving, dynamically typed language — which means: ✅ It tries to run the code anyway, even if something looks suspicious. ⚠️ It won’t complain until a real runtime problem occurs. ❗ So the responsibility shifts to the developer to be careful and deliberate. 🧠 Why JavaScript behaves this way JavaScript was originally designed for browsers — to make pages interactive without crashing due to small mistakes. For example: let x; console.log(x + 5); // NaN (Not an error, but “Not a Number”) A strict language (like C# or Java) would likely stop or throw an error at compile time, but JavaScript says “Hmm, x is undefined — let’s just try to do something.” 💡 Best practices to stay safe Use "use strict"; at the top of your JS file → catches common mistakes like undeclared variables. Prefer const and let instead of var. → Avoids hoisting and scope confusion. Use ESLint / Prettier — → automatically flags potential logic errors (like the one you caught). TypeScript if possible — → gives compile-time checking like C# while keeping JS flexibility. #JavaScript #WebDevelopment #ProgrammingTips #TypeScript #CodingBestPractices #FrontendDevelopment #SoftwareEngineering #LearningEveryday
To view or add a comment, sign in
-
✨I am excited to share about stages of errors in javascript. while learning JavaScript,i realized that errors are not just mistakes-they are an important part of how code works and how we debug efficiently. Types of errors in javascript: ➡️Syntax error:This happens before the code runs,when javascript checks the syntax. ex:console.log("Hello" //syntaxerror:missing paranthesis ➡️ Reference error:This error occurs while the program is running -after syntax checking ex: console.log(x) //reference error:x is not defined. ➡️Type error:A type error occurs when an operation or function is applied to a value of the wrong type. ex:let person console.log(person.name)//Type error: cannot read properties of undefined. ➡️A URI(Uniform Resource Identifier) occurs when a malformed uri is passed to a URI handling function. ex:decodeURI('%');//uri error:uri malformed ➡️Range error:A range error occurs when you give a function a value that's outside it's valid range,even though the type is correct. ex:let arr=new array(-2)//range error: Invalid array length #Javascript #webdevelopment #coding #Learningjourney #Debugging #10000coders #sudheervelpula
To view or add a comment, sign in
-
-
🛑 Still using this to deep clone objects in JavaScript? JSON.parse(JSON.stringify(obj)) It works… until it doesn’t 😅 It breaks with: ❌ Dates (turn into strings) ❌ Maps / Sets (lost completely) ❌ undefined & functions (removed) ❌ Circular references (throws error) JavaScript now has a modern, safer solution: structuredClone(obj) ✨ Supports circular references ✨ Preserves Date, Map, Set, RegExp ✨ Faster & built-in in modern JS/Node I wrote a simple blog with easy examples explaining why this matters, including a quick view of Shallow vs Deep cloning so the concept is crystal clear even for beginners. 🔗 Read it here: https://lnkd.in/dVcGiNwv #JavaScript #WebDevelopment #Programming #NodeJS #TypeScript #JSTips #CleanCode #SoftwareEngineering #Developers #WebDev #CodingLife
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