The language specification explicitly says:

If x is null and y is undefined, return true

I'm not aware of any records of the language design process that explain the reasoning for that decision, but == has rules for handling different types, and "null" and "undefined" are both things that mean "nothing", so having them be equal makes intuitive sense.

(If you don't want type fiddling, use === instead).

Answer from Quentin on Stack Overflow
🌐
web.dev
web.dev › learn › javascript › data-types › null-undefined
null and undefined | web.dev
null == undefined > true null === undefined > false · Unlike the reserved keyword null, undefined is a property of the global object. This was a design decision made early in JavaScript's development, and it let legacy browsers overwrite undefined completely.
Discussions

Why the heck is null != undefined evaluating to true in my code?
This is my code: const [value, ... nothing is in there yet. (prefixedKey is of course defined earlier in document) console.log('jsonValue: ' + jsonValue); // jsonValue: undefined console.log(jsonValue != null); // evaluates to true. Why? if (jsonValu...... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
0
July 17, 2022
Undefined vs null
One reason to favor undefined over null is how javascript handle default values: const withDefault = (a = true) => { console.log(a); }; withDefault(); // logs true withDefault(undefined); // logs true withDefault(null); // logs null More on reddit.com
🌐 r/typescript
51
46
February 27, 2023
What is the difference between null and undefined in JavaScript? - Stack Overflow
When you're debugging this means that anything set to null is of your own doing and not JavaScript. Beyond that, these two special values are nearly equivalent. ... Really a good answer. But just to point out, when u checked "undefined == null" the type checking was not strict. Hence it returned "true... More on stackoverflow.com
🌐 stackoverflow.com
why is null === undefined ?
I am doing this code challenge and I watched the video several times. I tried doing this in the console several times and I do not understand why null could be === to undefined. It is my understanding that null and undefined share the same type which would be mean that null == undefined is true. More on teamtreehouse.com
🌐 teamtreehouse.com
6
December 21, 2013
🌐
Web Dev Simplified
blog.webdevsimplified.com › 2021-01 › null-vs-undefined
Null Vs Undefined
January 11, 2021 - The reason you would want to do this is to essentially reset a variable. By setting a variable to undefined you are conveying the message that the variable no longer contains any useful information, while if the value is null then you are ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › undefined-vs-null-in-javascript
Undefined Vs Null in JavaScript - GeeksforGeeks
July 23, 2025 - null == undefined // true null === undefined // false · It means null is equal to undefined but not identical.
🌐
Quora
quora.com › Why-is-null-undefined-true-in-JavaScript
Why is (null==undefined) true in JavaScript? - Quora
Answer (1 of 7): Actually, there is no satisfactory reason for that. I am too confused with this. Some say both are actually falsy values, so it evaluates to true, but i don’t get this logic. I mean i want to know what thing is being converted to what if type coercion is happening.
🌐
Flexiple
flexiple.com › javascript › undefined-vs-null-javascript
Undefined vs Null - Javascript - Flexiple
March 10, 2022 - As you can see, when the equality operator is used it compares only the values. Both undefined and null are falsy by default. So == returns true.
Find elsewhere
🌐
Greenroots
blog.greenroots.info › javascript-undefined-and-null-lets-talk-about-it-one-last-time
JavaScript undefined and null: Let's talk about it one last time!
November 12, 2020 - A falsy (sometimes written falsey) value is a value that is considered false when encountered in a Boolean context. In JavaScript, there are 6 falsy values including undefined and null, ... Apart from the similarities mentioned above, undefined and null are way apart from each other. They are strictly not equal, (undefined === null) // returns, false (undefined !== null) // returns true...
🌐
CoreUI
coreui.io › blog › what-is-the-difference-between-null-and-undefined-in-javascript
What is the Difference Between Null and Undefined in JavaScript · CoreUI
February 9, 2025 - Unlike null, undefined means JavaScript cannot find a meaningful value. In contrast, null means a developer has explicitly assigned an empty value. The value null signals the intentional absence of data or object value.
🌐
Reddit
reddit.com › r/typescript › undefined vs null
r/typescript on Reddit: Undefined vs null
February 27, 2023 -

Since switching to TypeScript I have been using a lot of optional properties, for example:

type store = {
  currentUserId?: string
}

function logout () {
  store.currentUserId = undefined
}

However my coworkers and I have been discussing whether null is a more appropriate type instead of undefined, like this:

type store = {
  currentUserId: string | null
}

function logout () {
  store.currentUserId = null
}

It seems like the use of undefined in TypeScript differs slightly from in Javascript.

Do you guys/girls use undefined or null more often? And, which of the examples above do you think is better?

🌐
Syncfusion
syncfusion.com › blogs › post › null-vs-undefined-in-javascript
Null vs. Undefined in JavaScript | Syncfusion Blogs
December 10, 2024 - Despite both being falsy in a Boolean context, null or undefined is not loosely equal (==) to any other falsy value such as zero (0), an empty string (” “, ‘ ‘), or Not-a-Number (NaN). The only values null is loosely equal to are undefined and itself.
🌐
Medium
medium.com › @stephenthecurt › a-brief-history-of-null-and-undefined-in-javascript-c283caab662e
A brief history of Null and Undefined in JavaScript | by Steve C | Medium
January 13, 2018 - Null and undefined in JavaScript are actually values and types created to simulate errors and keywords common in other programming languages. When a variable is `undefined`, or unitialized, in most programming languages it means that a space in memory has been assigned to a variable name, but the programmer has not yet done anything with that space in memory.
🌐
Sentry
sentry.io › sentry answers › javascript › undefined versus null in javascript
Undefined versus null in JavaScript | Sentry
October 21, 2022 - console.log(undeclaredVar); // will throw a ReferenceError console.log(typeof undeclaredVar); // will print "undefined" In contrast, null is a value that represents nothing. Think of null as an empty container and undefined as the absence of ...
🌐
Scaler
scaler.com › topics › javascript › null-and-undefined-in-javascript
Null and Undefined in JavaScript - Scaler Topics
April 4, 2024 - Null in JavaScript means an empty value and is also a primitive type in JavaScript. The variable which has been assigned as null contains no value. Undefined, on the other hand, means the variable has been declared, but its value has not been assigned.
🌐
SheCodes
shecodes.io › athena › 2227-what-is-the-difference-between-null-and-undefined-in-javascript
[JavaScript] - What is the Difference Between Null and Undefined in JavaScript?
Learn what is the difference between null and undefined in JavaScript and how to distinguish between them. Check how to use a typeof operator.
🌐
CodeBurst
codeburst.io › javascript-null-vs-undefined-20f955215a2
JavaScript — Null vs. Undefined
January 16, 2018 - The code above creates a function named logHi. This function requires one parameter and sets the default of that parameter to hi if it isn’t supplied. Here’s what that looks like: ... With default parameters, undefined will use the default while null does not.