首页 > 其他 > 详细

检测类型

时间:2017-02-07 16:48:50      阅读:246      评论:0      收藏:0      [点我收藏+]

typeof

var s = "Nicholas";

var b =true;

var i =22;

var u;

var n =null;

var o =new Object();

alert(typeof s);  //string

alert(typeof i);  //number

alert(typeof b);  //boolean

alert(typeof u);  //undefined

alert(typeof n);  //object

alert(typeof o);  //object

instanceof

alert(person instanceof Object);  //变量person是Object吗?

alert(colors instanceof Array);  //变了colors是Array吗?

检测类型

原文:http://liuxinyun.blog.51cto.com/8263686/1895632

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!