继承最好方法
var inherit = (function (c, p) {
var F = function () { };
return function (c, p) {
F.prototype = p.prototype;
c.prototype = new F();
c.uber = p.prototype;
c.prototype.constructor = c;
}
})();
实现typeof
let class2type = {}
'Array Date RegExp Object Error'.split(' ').forEach(e => class2type['[object ' + e + ']'] = e.toLowerCase())
function type(obj) {
if (obj == null) return String(obj)
return typeof obj === 'object' ? class2type[Object.prototype.toString.call(obj)] || 'object' : typeof obj
}