JavaScript isNaN() function
- Página anterior isFinite()
- Página siguiente NaN
- Volver a la capa superior Manual de referencia global de JavaScript
Definition and usage
isNaN()
The function can determine if 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.
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. |
---|---|
Versión de JavaScript: | ECMAScript 1 |
Compatibilidad del navegador
Función | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
isNaN() | Soporte | Soporte | Soporte | Soporte | Soporte |
- Página anterior isFinite()
- Página siguiente NaN
- Volver a la capa superior Manual de referencia global de JavaScript