Home >Web Front-end >JS Tutorial >js isNaN函数判断变量是否是数值

js isNaN函数判断变量是否是数值

WBOY
WBOYOriginal
2016-06-01 09:55:081725browse

实例:

<code><script type="text/javascript">
alert(isNaN("123"));//弹出false;
alert(isNaN("12codeshare"));//弹出true;
</script></code>

注意:

使用isNaN()函数判断是否是数字时,当变量是空串时,isNaN()的返回值还是false,因为isNaN()把空串或空格作0处理的。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn