一元加操作符

2017-06-14 16:20:00
admin
原创
295
<!DOCTYPE html>
<html>
	<head>
		<title>
			Unary Plus/Minus Example 1
		</title>
		<script type="text/javascript">
			var s1 = "01";
			var s2 = "1.1";
			var s3 = "z";
			var b = false;
			var f = 1.1;
			var o = {
				valueOf: function() {
					return - 1;
				}
			};

			s1 = +s1; //value becomes numeric 1
			s2 = +s2; //value becomes numeric 1.1
			s3 = +s3; //value becomes NaN
			b = +b; //value becomes numeric 0
			f = +f; //no change, still 1.1
			o = +o; //value becomes numeric
			alert(s1);
			alert(s2);
			alert(s3);
			alert(b);
			alert(f);
			alert(o);
		</script>
	</head>
	<body>
	</body>
</html>
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227