undefined means a variable has been declared but has not yet been assigned a value :

var testVar;
console.log(testVar); //shows undefined
console.log(typeof testVar); //shows undefined

null is an assignment value. It can be assigned to a variable as a representation of no value :

var testVar = null;
console.log(testVar); //shows null
console.log(typeof testVar); //shows object

From the preceding examples, it is clear that undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.

Proof :

console.log(null === undefined) // false (not the same type)
console.log(null == undefined) // true (but the "same value")
console.log(null === null) // true (both type and value are the same)

and

null = 'value' // Uncaught SyntaxError: invalid assignment left-hand side
undefined = 'value' // 'value'
Answer from sebastian on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › undefined-vs-null-in-javascript
Undefined Vs Null in JavaScript - GeeksforGeeks
July 23, 2025 - ... let x; // variable declared ... console.log(obj.property); // Output: undefined ... null is a special value in JavaScript that represents the deliberate absence of any object value....
🌐
web.dev
web.dev › learn › javascript › data-types › null-undefined
null and undefined | web.dev
The strict equality operator considers operands of different data types to be unequal. null == undefined > true null === undefined > false · Unlike the reserved keyword null, undefined is a property of the global object.
🌐
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 - ... In the original JavaScript implementation, undefined means a variable has been declared but has not been assigned a value. For instance, if you write: ... without assigning a value, you end up with an undefined variable.
🌐
Scaler
scaler.com › topics › javascript › null-and-undefined-in-javascript
Null and Undefined in JavaScript - Scaler Topics
April 21, 2022 - 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.
🌐
DEV Community
dev.to › sduduzog › null-vs-undefined-what-to-choose-what-to-use-11g
null vs undefined? What to choose? What to use? - DEV Community
August 23, 2023 - "But black dynamite, assigning null to a variable does the same thing" see that's where you'd be wrong. Here's an analogy for you. We can say null is like loading a webpage and just getting a blank screen, but undefined is a '404 not found' error.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › null
null - JavaScript | MDN
For example, the end of the prototype chain is null because the prototype chain is composed of objects; document.querySelector() returns null if it doesn't match, because had it matched, the result would be an object. If you are designing an API, you should likely accept null and undefined ...
Find elsewhere
🌐
Syncfusion
syncfusion.com › blogs › post › null-vs-undefined-in-javascript
Null vs. Undefined in JavaScript | Syncfusion Blogs
December 10, 2024 - Some of the significant differences between null and undefined are: JavaScript always assigns undefined to indicate the absence of a value by default, and it never automatically assigns null as a value.
🌐
Web Dev Simplified
blog.webdevsimplified.com › 2021-01 › null-vs-undefined
Null Vs Undefined
If a variable is set to null or undefined it has no value and if a function returns null or undefined then it is saying it has no value to return. This you most likely already understand.
🌐
Flexiple
flexiple.com › javascript › undefined-vs-null-javascript
Undefined vs Null - Javascript - Flexiple
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 · 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. But when we use the strict equality operator (===) which checks both type and value, since undefined and null are of different types (from the typeof Operator section), the strict equality operator returns false.
🌐
Medium
medium.com › weekly-webtips › null-and-undefined-in-javascript-d9bc18acdaff
Null and Undefined in Javascript. What’s the difference between null and… | by Megan Lo | Webtips | Medium
February 17, 2021 - Pretty cool, right? Also I would like to point out another practical example I saw from another topic-related post. With default parameters in a function, undefined will use the default parameter while null does not.
🌐
TutorialsTeacher
tutorialsteacher.com › javascript › javascript-null-and-undefined
Difference between null and undefined in JavaScript
A null means the absence of a value. You assign a null to a variable with the intention that currently this variable does not have any value but it will have later on. It is like a placeholder for a 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?

🌐
Medium
designtechworld.medium.com › what-is-the-difference-between-null-and-undefined-in-javascript-fa8ad03938a3
What is the Difference Between Null and Undefined in JavaScript? | by Sumit kumar Singh | Medium
April 4, 2023 - It is often used to assign an empty ... // null · In the above example, the variable is assigned a value of null, which indicates that it intentionally does not have any value....
🌐
Kettanaito
kettanaito.com › blog › the-difference-between-null-and-undefined
The Difference Between Null and Undefined - kettanaito.com
undefined is a literal type. That's why you check typeof thing === 'undefined' to know if the type of thing is not defined at all. null is an object. If you find that wierd, the next sentence will rock your world upside down.
🌐
TutorialsPoint
tutorialspoint.com › What-is-the-difference-between-null-and-undefined-in-JavaScript
What is the difference between null and undefined in JavaScript?
In JavaScript, use null to explicitly indicate that a variable has no value or is intentionally empty. Use undefined when something is naturally missing, such as an uninitialized variable or a non-existing object property.
🌐
Bits Kingdom
bitskingdom.com › home › development › what’s the difference between null and undefined in javascript?
Difference Between null and undefined: A JavaScript Guide
December 16, 2024 - null signifies an explicit setting of “no value.” This is useful for resetting or clearing a variable, making your intent clear to other developers. ... undefined is the default for unassigned variables and non-existent properties, often ...
Price   $$
Address   3235 Satellite Blvd Building 400 Suite 550, 30096, Duluth
🌐
CodeBurst
codeburst.io › javascript-null-vs-undefined-20f955215a2
JavaScript — Null vs. Undefined. Learn the differences and similarities… | by Brandon Morelli | codeburst
January 16, 2018 - We assign the value of null to a: ... Undefined most typically means a variable has been declared, but not defined. For example: ... In JavaScript there are only six falsy values. Both null and undefined are two of the six falsy values.