- Notifications
You must be signed in to change notification settings - Fork 3
Private methods
dotnetwise edited this page Mar 28, 2013
·
3 revisions
You can add as many private methods you want in your derived classes by simply declaring them in the creator function (the function you give as a parameter to either .fastClass or .inheritWith
varA=function(val){this.val=val;}.define({method1: function(x,y,z){this.x=x;this.y=y;this.z=z;}});varB=A.fastClass(function(base,baseCtor){functionprivateMethod(z){this.z="some private value"+z;}this.constructor=function(val){baseCtor.call(this,val)},this.method1=function(y,z){base.method1.call(this,'x',y,z);privateMethod.call(this,z);}});varb=newB("b");b.method1("y","z");b.z;//"some private value z"