首页 > 网站 > WEB开发 > 正文

javaScript之typeof测试

2024-04-27 15:11:55
字体:
来源:转载
供稿:网友
<html>  <head>    <base href="<%=basePath%>">        <title>JS typeof测试</title>  </head>  <body>  <script>document.write ("typeof(1): "+typeof(1)+"<br>");document.write ("typeof(NaN): "+typeof(NaN)+"<br>");document.write ("typeof(Number.MIN_VALUE): "+typeof(Number.MIN_VALUE)+"<br>")document.write ("typeof(Infinity): "+typeof(Infinity)+"<br>")document.write ("typeof(/"123/"): "+typeof("123")+"<br>")document.write ("typeof(true): "+typeof(true)+"<br>")document.write ("typeof(window): "+typeof(window)+"<br>")document.write ("typeof(document): "+typeof(document)+"<br>")document.write ("typeof(null): "+typeof(null)+"<br>")document.write ("typeof(eval): "+typeof(eval)+"<br>")document.write ("typeof(Date): "+typeof(Date)+"<br>")document.write ("typeof(sss): "+typeof(sss)+"<br>")document.write ("typeof(undefined): "+typeof(undefined)+"<br>")document.write ("typeof(1,2,3): "+typeof(1,2,3)+"<br>")</script><br>  </body></html>

结果:

typeof(NaN): numbertypeof(Number.MIN_VALUE): numbertypeof(Infinity): numbertypeof("123"): stringtypeof(true): booleantypeof(window): objecttypeof(document): objecttypeof(null): objecttypeof(eval): functiontypeof(Date): functiontypeof(sss): undefinedtypeof(undefined): undefinedtypeof(1,2,3): number


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表