js 判断各种数据类型

如果有一个变量 var a  = 1;js判断a的类型有几种方法:

1、typeof (a) 或者  typeof a ;   // number

2、Object.prototype.toString.call(a)  // number

3、jquery.type(a)   // number

4、判断已知对象类型的方法: instanceof    

 a instanceof Number    // true

5、根据对象的constructor判断: constructor

   a.constructor === Number    // true

posted on 2017-09-14 17:45  程序猿-alvin  阅读(151)  评论(0编辑  收藏  举报

导航