MDN wants to learn about developers like you:

Esta tradução está incompleta. Por favor, ajude a traduzir este artigo do Inglês.

This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.

O método Number.isNaN() determina se o valor passado é NaN. Esta é uma versão mais robusta que isNaN().




O valor a ser testado se é NaN.


Due to both equality operators, == and ===, evaluating to false when checking if NaN is NaN, the function Number.isNaN() has become necessary. This situation is unlike all other possible value comparisons in JavaScript.

In comparison to the global isNaN() function, Number.isNaN() doesn't suffer the problem of forcefully converting the parameter to a number. This means it is now safe to pass values that would normally convert to NaN, but aren't actually the same value as NaN. This also means that only values of the type number, that are also NaN, return true.


Number.isNaN(NaN);        // true
Number.isNaN(Number.NaN); // true
Number.isNaN(0 / 0)       // true

// e.g. these would have been true with global isNaN()
Number.isNaN("NaN");      // false
Number.isNaN(undefined);  // false
Number.isNaN({});         // false
Number.isNaN("blabla");   // false

// These all return false
Number.isNaN(" ");


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


Especificação Estado Comentário
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Number.isnan' in that specification.
Standard Definição inicial.

Compatibilidade dos browsers

Funcionalidade Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 25 15 (15) Not supported (Yes) 9
Funcionalidade Android Chrome para Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported ? 15.0 (15) Not supported Not supported iOS 9+

Ver também

Etiquetas do documento e contribuidores

 Contribuidores para esta página: Redeagle48
 Última atualização por: Redeagle48,