varClass =function(){ varKlass =function(){ This. init.apply ( This, arguments); } klass.prototype.init=function() {} Klass.fn=Klass.prototype; Klass.fn.parent=Klass; //properties of the object are copied directly to the classKlass.extend =function(obj) {varExtended =obj.extended; for(varIinchobj) {Klass[i]=Obj[i]; } if(Extended) Extended (Klass)}//The properties of the object are copied into the prototype of the classKlass.include =function(obj) {varincluded =obj.included; for(varIinchobj) {Klass.fn[i]=Obj[i]; } if(included) included (Klass)}returnKlass; }
Use the Extend () function to generate a class in which the parameter of the function is an object. To copy the properties of an object directly onto a class by iterating:
var New Class; Person.extend ({ find:function() {}, exists:function() {} }) ; var person = person.find (1);