Friday, May 12, 2017

Number.isNaN() & Polyfill

The Number.isNaN() method determines whether the passed value is NaN and its type is Number. It is a more robust version of the original, global isNaN().

 Internet Explorer   No support

Polyfill

Number.isNaN = Number.isNaN || function(value) {
    return typeof value === 'number' && isNaN(value);
}

// Or
Number.isNaN = Number.isNaN || function(value) {     
    return value !== value;
}
@reference_1_mozilla

No comments:

Post a Comment