- typeof 其中數組 對象 null都會判斷為Object,其他正確
typeof 2 // number
typeof true //bolean
typeof 'str' //string
typeof [] //Object
typeof function (){} // function
typeof {} //object
typeof undefined //undefined
typeof null // null
- instanceof 判斷引用類型,其內部機制就是判斷其原型鏈上是否存在該類型的原型
2 instanceof Number //false
true instanceof Boolean //false
'str' instanceof String //false
[] instanceof Array //true
{} instanceof Object //true
function(){} instanceof Function //true
- constructor 對象訪問它構造函數
(2).constructor === Number //true
(true).constructor ==Boolean //true
- Object.prototype.toString.call()
Object.prototype.toString.call(2) == '[object Number]'