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

原文地址:https://www.cnblogs.com/alvin553819/p/7521877.html