javascript typeof 小结

本文通过一系列JavaScript代码演示了如何检测各种数据类型,包括基本类型如数字、字符串、布尔值,以及特殊值如NaN、Infinity等。此外,还展示了如何检测对象和未定义变量。
ContractedBlock.gifExpandedBlockStart.gif代码
1 <style>
2 body{font-size:20px;color:#222222;font-family:宋体;line-height:22px;}
3  </style>
4  
5 <script>
6 document.write ("typeof(1): "+typeof(1)+"<br>");
7 document.write ("typeof(NaN): "+typeof(NaN)+"<br>");
8 document.write ("typeof(Number.MIN_VALUE): "+typeof(Number.MIN_VALUE)+"<br>")
9 document.write ("typeof(Infinity): "+typeof(Infinity)+"<br>")
10 document.write ("typeof(\"123\"): "+typeof("123")+"<br>")
11 document.write ("typeof(true): "+typeof(true)+"<br>")
12 document.write ("typeof(window): "+typeof(window)+"<br>")
13 document.write ("typeof(document): "+typeof(document)+"<br>")
14 document.write ("typeof(null): "+typeof(null)+"<br>")
15 document.write ("typeof(eval): "+typeof(eval)+"<br>")
16 document.write ("typeof(Date): "+typeof(Date)+"<br>")
17 document.write ("typeof(sss): "+typeof(sss)+"<br>")
18 document.write ("typeof(undefined): "+typeof(undefined)+"<br>")
19 </script>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值