201606011000_《JavaScript通用的创建函数》

function New(oClass,oParams) {

      function new_(){

       oClass.Create.apply(this,oParams);

  };

  new_.prototype = aClass;

  return new new_();

};

 

 

===================使用=======================

var Person = {

Create:function(name,age) {

//todo

},

someMthod() {

//todo

}

};

 

var billGate = New(Person,["billGate",74]);

billGate.someMethod();

你可能感兴趣的:(JavaScript)