In JavaScript, object creation is prototype-based...an object creating function can have a prototype property, and any object assigned to that property will be used as a prototype for the objects created with that function.http://en.wikipedia.org/wiki/Prototype_JavaScript_Framework
Object.prototype.inObj = 1; function A(){ this.inA = 2;} A.prototype.inAProto = 3; B.prototype = new A; // Hook up A into B's prototype chainB.prototype.constructor = B;function B(){ this.inB = 4;} B.prototype.inBProto = 5; x = new B;document.write(x.inObj + ', ' + x.inA + ', ' + x.inAProto + ', ' + x.inB + ', ' + x.inBProto);
String.prototype.trim = function () {return this.replace(/^\s+|\s+$/g, "");};
No comments:
Post a Comment