JavaScript isNaN() function
- Página anterior isFinite()
- Próxima página NaN
- Voltar à página anterior Manual de referência global do JavaScript
Definition and usage
isNaN()
The function can determine whether the value is a non-numeric (Not-a-Number).
If the value equals NaN, this function returns true. Otherwise, it returns false.
This function is different from the Number-specific Number.isNaN() method.
The global isNaN() function converts the value to a number and then tests it.
The Number.isNaN() method does not convert the value to a number and does not return true for any non-numeric value types.
Example
Check if the value is NaN:
isNaN(123) //false isNaN(-1.23) //false isNaN(5-2) //false isNaN(0) //false isNaN('123') //false isNaN('Hello') //true isNaN('2005/12/12') //true isNaN('') //false isNaN(true) //false isNaN(undefined) //true isNaN('NaN') //true isNaN(NaN) //true isNaN(0 / 0) //true isNaN(null) //false
Syntax
isNaN(value)
Parameter value
Parameter | Description |
---|---|
value | Required. The value to be tested. |
Technical details
Return value: | Boolean value. If the value is NaN, it returns true, otherwise it returns false. |
---|---|
Versão do JavaScript: | ECMAScript 1 |
Suporte do navegador
Função | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
isNaN() | Suporte | Suporte | Suporte | Suporte | Suporte |
- Página anterior isFinite()
- Próxima página NaN
- Voltar à página anterior Manual de referência global do JavaScript