Copy code code as follows:
<script type= "text/javascript" >
function Base () {}//Root abstract class
Base . Tobase=function () {//method to convert an object to an instance of the Base class
return new Base ();
}
Base.inherit=function (parent) {//method for inheriting an instance of the Base class
var f=function () {}
F.prototype=parent;
return new F;
}
Base.prototype.extend = function (prop) {//extension root abstract class Base extend method
for (Var o in prop) {
This[o] = Prop [O];
}
}
Base.prototype.method = function (name, FN) {//extension root abstract class Base method
This[name] = fn;
return this;
}
Var o=new base ();////Create a base instance
O.method ("show", the function () {//To add to the object "O"-Method
Alert ("Show function");
});
O.extend ({//The Add Name property and say function to object o
Name: "Shupersha",
Say:function () {
Alert ("Say Function")
} br>});
var t=base.inherit (o);//Inheritance O object's properties and Methods
T.show ();
T.say ();
</script>