Number.isNaN

It is proposed that an isNaN property be added to the Number constructor. It could be implemented like this:

(function (global) {
    var global_isNaN = global.isNaN;
 
    Object.defineProperty(Number, 'isNaN', {
        value: function isNaN(value) {
            return typeof value === 'number' && global_isNaN(value);
        },
        configurable: true,
        enumerable: false,
        writable: true
    });
})(this);

This is better than the global isNaN function because it is not confused by type coercion.

Douglas Crockford 2010/12/15 20:27Brendan Eich 2011/04/28 00:20

 
harmony/number.isnan.txt · Last modified: 2011/04/28 00:54 by brendan
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki