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.
🌐
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.
🌐
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.
🌐
Web Dev Simplified
blog.webdevsimplified.com › 2021-01 › null-vs-undefined
Null Vs Undefined
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 ...
🌐
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?

Find elsewhere
🌐
Sentry
sentry.io › sentry answers › javascript › undefined versus null in javascript
Undefined versus null in JavaScript | Sentry
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 ...
🌐
Flexiple
flexiple.com › javascript › undefined-vs-null-javascript
Undefined vs Null - Javascript - Flexiple
As you can see here, both, variable t which is undefined and variable a which is see to null, return false and hence do not satisfy either of the if conditions and return the output "both t and a are not defined with a value". Let’s see what happens when you compare undefined and null using the JavaScript equality operators. // comparing undefined and null undefined == null; //true undefined === null; //false
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › null
null - JavaScript | MDN
The keyword null is a literal for the null value. Unlike undefined, which is a global variable, null is not an identifier but a syntax keyword.
🌐
Syncfusion
syncfusion.com › blogs › javascript › 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.
🌐
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 6, 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...
🌐
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.
🌐
Quora
quora.com › What-is-the-difference-between-undefined-null-and-false
What is the difference between 'undefined', 'null', and 'false'? - Quora
Answer: In most programming languages there is undefined, null, and false is a value given to a Boolean variable. When it comes to any variable null means that it wasn’t assigned any value. And undefined it means that the variable wasn’t even declared(for example trying to print a variable a th...
🌐
TutorialsTeacher
tutorialsteacher.com › javascript › javascript-null-and-undefined
Difference between null and undefined in JavaScript
You must explicitly assign a null to a variable. A variable has undefined when no value assigned to it. ... The '' is not the same as null or undefined.
🌐
Bitstack
blog.bitsrc.io › understanding-null-and-undefined-in-javascript-77ceb44cf7db
JavaScript: Everything about Null and Undefined | by Chidume Nnamdi | Bits and Pieces
January 2, 2026 - undefined variables are variables that are with no values. Let’s say the environment is represented like this:
🌐
Programiz
programiz.com › javascript › null-undefined
JavaScript null and undefined
console.log(null == undefined); // true · In JavaScript, == compares values by performing type conversion. Both null and undefined return false. Hence, null and undefined are considered equal. However, when comparing null and undefined with strict equal to operator ===, the result is false.