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

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

WBOY
Release: 2016-06-01 09:55:08
Original
1761 people have browsed it

实例:

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

注意:

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template