isNaN():判断一个变量不是number,若这个变量不是number则返回true,若是number则返回false。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var a = 123;
var b = "string";
alert(isNaN(a)); //false
alert(isNaN(b)); //true
function isNAN(a){
if (isNaN(a)) {
alert("a = "+a+"不是一个数字");
}else{
alert("a = "+a+"是一个数字");
}
}
isNAN(a);
isNAN(b);
console.log(a==isNaN(a));
</script>
</body>
</html>