一.typeof
typeof 666
typeof '666'
typeof undefined
typeof true
typeof Symbol()
typeof null
typeof []
typeof {}
二.instanceof
function C(){}
function D(){}
var o = new C();
o instanceof C;
o instanceof D;
o instanceof Object;
C.prototype instanceof Object
C.prototype = {};
var o2 = new C();
o2 instanceof C;
o instanceof C;
D.prototype = new C();
var o3 = new D();
o3 instanceof D;
o3 instanceof C;
三.使用Object.prototype.toString.call()
注意:精确判断对象的类型
console.log(Object.prototype.toString.call("jerry"));
console.log(Object.prototype.toString.call(12));
console.log(Object.prototype.toString.call(true));
console.log(Object.prototype.toString.call(undefined));
console.log(Object.prototype.toString.call(null));
console.log(Object.prototype.toString.call({name: "jerry"}));
console.log(Object.prototype.toString.call(function(){}));
console.log(Object.prototype.toString.call([]));
console.log(Object.prototype.toString.call(new Date));
console.log(Object.prototype.toString.call(/\d/));
function Person(){};
console.log(Object.prototype.toString.call(new Person));