NaN means Not a number, and it denotes the value of an object is not a number. If you look at
typeof NaN it will return
NaN is a numeric data type that is undefined as a real number.
NaN can be returned if you do one of the following:
undefinedinto a number
- Convert a non-numeric string into a number
- Divide zero by zero
- Divide infinity by infinity
- Operation where the result is not a real number
- Method/expression’s operand is or gets coerced to
null means the object is empty. It’s an assignment value that can be assigned to a variable that has no value.
undefined means that the object doesn’t have any value and is undefined. This happens when you declare a variable and don’t assign a value to it.