typeof判断数据类型

来源:互联网 发布:java九阴真经 编辑:程序博客网 时间:2024/05/19 13:28

var test=xxx;

alert(typeof xxx=='yyy');

注意:不管xxx是什么,yyy都要加上双引号、

var a='4399'-0;
alert(typeof a=='number');//true

var test=null;
alert(typeof test=='object');//true


var test=1.2;
alert(typeof test=='float');//flase


其它检测方法:转载自:http://www.cnblogs.com/onepixel/p/5126046.html




阅读全文
0 0
原创粉丝点击