toString.call() / Object.prototype.toString.call('') ; // [object String]通用的
toString.call(1) ; // [object Number]
toString.call(true) ; // [object Boolean]
toString.call(Symbol()); //[object Symbol]
toString.call(undefined) ; // [object Undefined]
toString.call(null) ; // [object Null]
toString.call(new Function()) ; // [object Function]
toString.call(new Date()) ; // [object Date]
toString.call([]) ; // [object Array]
toString.call(new RegExp()) ; // [object RegExp]
toString.call(new Error()) ; // [object Error]
toString.call(document) ; // [object HTMLDocument]
toString.call(window) ; //[object global] window 是全局对象 global 的引用
Object.prototype.toString.call(1) ; // [object Number]
Object.prototype.toString.call(true) ; // [object Boolean]
Object.prototype.toString.call(Symbol()); //[object Symbol]
Object.prototype.toString.call(undefined) ; // [object Undefined]
Object.prototype.toString.call(null) ; // [object Null]
Object.prototype.toString.call(new Function()) ; // [object Function]
Object.prototype.toString.call(new Date()) ; // [object Date]
Object.prototype.toString.call([]) ; // [object Array]
Object.prototype.toString.call(new RegExp()) ; // [object RegExp]
Object.prototype.toString.call(new Error()) ; // [object Error]
Object.prototype.toString.call(document) ; // [object HTMLDocument]
Object.prototype.toString.call(window) ; //[object global] window 是全局对象 global 的引用
typeof 可以判断number,boolean,string,function,它返回表示数据类型的字符串。
不能判断空,不能区分对象
typeof null // object
typeof [8] // object
typeof {a:1,b:2,c:3} // object
typeof /\s/ // object
typeof new Date() // object
typeof new Error() // object
typeof undefined // undefined
typeof 123 // number
typeof typeof 123, //"number"
typeof 'dsfsf', //"string"
typeof false, //"boolean"
typeof function(){console.log('aaa');}, //"function"
其他类型toString.call()