Open newPromise opened 6 years ago
使用 Object.prototype.toString() 方法返回的是一个字符串,返回 '[object, type]', 其中 type 指的是对象的类型: 对于对象上,存在 toString() 方法
Object.prototype.toString()
'[object, type]'
type
let o = new Object(); o.toString(); // [Object Object]
使用 call 语法可以实现获得一个函数的类 ?
call
function s() {}; let s1 = new s(); let toString = Object.prototype.toString; toString.call(s1); [Object Object]
let toString = Object.prototype.toString; toString.call(new Date); [Object Date]; toString.call(new String) [Object String];
使用
Object.prototype.toString()
方法返回的是一个字符串,返回'[object, type]'
, 其中type
指的是对象的类型: 对于对象上,存在 toString() 方法使用
call
语法可以实现获得一个函数的类 ?