递增和递减还可以用于字符串、布尔值、浮点数值和对象

2017-06-14 16:18:00
admin
原创
318
<!DOCTYPE html>
<html>
	<head>
		<title>
			Increment/Decrement Example 4
		</title>
		<script type="text/javascript">
			var s1 = "2";
			var s2 = "z";
			var b = false;
			var f = 1.1;
			var o = {
				valueOf: function() {
					return - 1;
				}
			};
			s1++; //value becomes numeric 3
			s2++; //value becomes NaN
			b++; //value becomes numeric 1
			f--; //value becomes 0.10000000000000009
			o--; //value becomes numeric
			alert(s1);
			alert(s2);
			alert(b);
			alert(f);
			alert(o);
		</script>
	</head>
	<body>
	</body>
</html>
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227