gattsbr gattsbr - 1 year ago 104
Javascript Question

ReferenceError: 'number' is undefined

In my code I'm trying to explicitly assign the javascript value of NaN to a variable.

This is the mistake I make occasionally:

var myVar = number.NaN;

Answer Source

The answer to this is simple. It's not number.NaN but Number.NaN

var myVar = Number.NaN;