Null and undefined are two distinct types in JavaScript.

Undefined:
Undefined means a variable has been declared but has not yet been assigned a value.
Example:
let x;
console.log(x); // Output: undefined

Null:
Null is an assignment value. It can be assigned to a variable as a representation of no value.
Example:
let x = null;
console.log(x); // Output: null

Leave a Reply

Your email address will not be published. Required fields are marked *