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();

posted @ 2015-06-01 10:11  Coca-code  阅读(117)  评论(0编辑  收藏  举报