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
🌐
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.
🌐
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...
🌐
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.
🌐
Net Informations
net-informations.com › js › iq › nuvsun.htm
Null and Undefined in JavaScript
Unlike undefined, null is explicitly assigned. var z = null; console.log(z); // Output: null var user = null; console.log(user); // Output: null var arr = [1, 2, 3]; arr = null; console.log(arr); // Output: null · console.log(undefined == null); // Output: true console.log(undefined === null); // Output: false
🌐
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 ...
🌐
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
🌐
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.
🌐
GitConnected
levelup.gitconnected.com › javascript-null-vs-undefined-2acda986f79f
JavaScript Null vs Undefined. Understanding the difference between… | by Aiman Rahmat | Level Up Coding
January 30, 2020 - So by not declaring a value to a variable, JavaScript automatically assigns the value to undefined. However, when you assign null to a variable, you are declaring that this value is explicitly empty.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › undefined-vs-null-in-javascript
Undefined Vs Null in JavaScript
July 23, 2025 - null == undefined // true null === undefined // false · It means null is equal to undefined but not identical.
🌐
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 ...
🌐
Movie Cultists
moviecultists.com › why-undefined-null-is-true
Why undefined == null is true?
The == comparison operator doesn't check the types. null and undefined both return false . That's why your code is actually checking if false is equal to false . However their types are not equal. However, if you coerce null to a number it is coerced to +0 so +null == false actually returns true .
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-determine-if-variable-is-undefined-or-null-in-javascript.php
How to Determine If Variable is Undefined or NULL in JavaScript
In JavaScript if a variable has been declared, but has not been assigned a value, is automatically assigned the value undefined. Therefore, if you try to display the value of such variable, the word "undefined" will be displayed.
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › null
null - JavaScript | MDN
May 23, 2022 - 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.
🌐
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.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-nullable-how-to-check-for-null-in-js
JavaScript Nullable – How to Check for Null in JS
July 7, 2022 - null == undefined evaluates as true because they are loosely equal. null === undefined evaluates as false because they are not, in fact, equal. <null_variable> === null is the best way to strictly check for null.