function Person(){}
Person.prototype.dance = function(){};
function Ninja(){}
Ninja.prototype = new Person();
//因为上方设置原型,导致了constructor也被指向了Person,手动改回来
Object.defineProperty(Ninja.prototype,"constructor",{
enumerable:false,//不可遍历
value:Ninja,
writable:true
}
网友评论