Object.prototype.toString.apply()方法獲得對象類型

Object.prototype.toString.apply([1,2])    //"[object Array]"
Object.prototype.toString.apply('str')    //"[object String]"
Object.prototype.toString.apply(1)        //"[object Number]"
Object.prototype.toString.apply(null)     //"[object Null]"
Object.prototype.toString.apply()         //"[object Undefined]"
Object.prototype.toString.apply(function(){})      //"[object Function]"
Object.prototype.toString.apply(true)     //"[object Boolean]"
Object.prototype.toString.apply(new Object())     //"[object Object]"
相關文章
相關標籤/搜索