As shown below:
Function.prototype.method = function (name, FN) {
This.prototype[name] = Fn;//this refers to the Function.prototype object
Return this;//returns this object, which facilitates cascading operations like JQ
};
Number.method ("Interge", function () {
});//number is a constructor, so it has the above method, so it finally returns the number object (constructor), so you can ( -10/ 3). Interge () to be
continued.
//Main is the method
of calling the parent class Obj.method ("Surper", function (name) {
var = this;
var method = That[name];
return function () {return
method.apply (that,arguments);//If there is not that, there will be no cat.getname (that is an object)
}
});/ /The following is an application of
var Coolcat = function (spec) {
var that = cat (spec);/personal feeling here, where that can have cat there are "some methods"
var GetName = That.surper ("GetName");//The feeling here should be done with the newly generated object, which should be better. It's best not to that.
That.get_name= function () {return
"Me" +getname () + "Me";
}
return that;
}
The above comes from "the JavaScript language pristine," which is really good.
The above JS rewrite method of simple implementation is small to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud-dwelling community.