var Person = function()
{
function Person(name,age)
{
if(!(this instanceof Person))
throw Error(“Must Use NEW”);
this.name = age;
this.age = age;
}
_prototype(Person,[{key:“saynothing”, value:function saynothing()}
{
},{}])
}()
var = New Person(“11”,11);
//为什么不直接用prototype。name = {};
因为这样无法直接继承其enumerable等特性。
_prototype(Constructor.prototype,prototype, staticprototype)
{
//(construcor.prototype, prototype)
for(var i in prototype)
var descriptor = prototype[i];
decscriptor.enumerable = descriptor.enumerable||false
descriptor.configurable = true;
//当get,set函数的时候是没有value的
if(“value” in descriptor)
descriptor.writable = true;
Object.defineProperties( Constructor.prototype, descriptor.key,
descriptor)
//(constructor, staticprototype)
}