java中isnan函数_isNaN()函数以及JavaScript中的示例

java中isnan函数

Prerequisite: NaN property in JavaScript

先决条件: JavaScript中的NaN属性

isNaN()函数 (isNaN() function)

isNaN() function is a predefined global function in JavaScript and it is used to check whether a given value is an illegible number or not. If the given value is an illegal number - it returns true and if the given value is a legal number – it returns false.

isNaN()函数是JavaScript中预定义的全局函数,用于检查给定值是否为难以辨认的数字。 如果给定值是非法数字-则返回true ;如果给定值是合法数字-则返回false 。

Example:

例:

<html>
<head>
<title>JavaScipt Example</title>
</head>

<body>
	<script>
		var num1 = 10;
		var num2 = parseInt("Hello");
		
		//printing the values
		document.write("num1: " + num1 + "<br>");
		document.write("num2: " + num2 + "<br>");		
		
		//checking illegal value using isNaN() function
		if(isNaN(num1))
			document.write("num1 is an illegal number <br>");
		else
			document.write("num1 is a legal number <br>");

		if(isNaN(num2))
			document.write("num2 is an illegal number <br>");
		else
			document.write("num2 is a legal number <br>");			
	</script>
</body>
</html>

Output

输出量

num1: 10
num2: NaN
num1 is a legal number 
num2 is an illegal number 


翻译自: https://www.includehelp.com/code-snippets/isNaN-function-with-example-in-javascript.aspx

java中isnan函数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值