手写实现hasPubProperty方法

283 阅读1分钟

//是否是 共有属性

Object.prototype.hasPubPrototype = function(key){

if(key in this && !this.hasOwnPrototype(key))return true;

return false;

}

''.hasOwnProperty('length')//true