1、typeof
准确的判断基本数据类型
对于复杂数据类型判断不准确
typeof 123
typeof 'abc'
typeof true
typeof undefined
typeof null
typeof {}
typeof []
typeof new Date
typeof function() {}
2、constructor
123.constructor
‘abc’.constructor
true.constructor
[].constructor
(function(){}).constructor
(new Date()).constructor
undefined.constructor
null.constructor
3、instanceof
4、Object.prototype.toString.call()
最完美方法
Object.prototype.toString.call(123)
Object.prototype.toString.call('abc')
Object.prototype.toString.call(true)
Object.prototype.toString.call(null)
Object.prototype.toString.call(undefined)
Object.prototype.toString.call(new Date())
Object.prototype.toString.call(function(){})
Object.prototype.toString.call([])
Object.prototype.toString.call({})