For example, if you declare a variable but do not assign a value to it, its value will be undefined:
console.log(x); // prints "undefined"
On the other hand, null is a value that represents the intentional absence of any object value. It is often used to indicate that a variable or property has no value, or that a function returns no value.
For example, you can explicitly assign null to a variable:
let y = null;
console.log(y); // prints "null"
In summary, undefined represents the absence of a value because a variable has not been assigned a value or a property does not exist, while null represents the intentional absence of any object value.