对象的class属性如何理解,与typeof有何区别?
这一页ppt有点混淆了:
var toString = Object.prototype.toString;
function getType(o){return toString.call(o).slice(8,-1);};
toString.call(null); // "[object Null]"
getType(null); // "Null"
getType(undefined); // "Undefined"
getType(1); // "Number"
getType(new Number(1)); // "Number"
typeof new Number(1); // "object"
getType(true); // "Boolean"
getType(new Boolean(true)); // "Boolean"