var a = NaN
var a = Number.NaN
We will see some examples of operations that return NaN.
Example 1: Whenever we try to parse a string or “undefined” to an int, it returns NaN.
Example 2: Whenever we try to find square root of a negative number using Math.sqrt function, it returns NaN.
Example 3: Whenever we try to make on operation on NaN, it returns NaN.
Example 4: Any indeterminate form also returns NaN.
Example 5: Any operation other than addition on a string also results in NaN.
- Chrome 1 and above
- Edge 12 and above
- Firefox 1 and above
- Internet Explorer 4 and above
- Opera 3 and above
- safari 1 and above