functionInherited(arg1,arg2){this.arg1=arg1;this.arg2=arg2;}// function Base(...args){// Inherited.apply(this,args);// this.arg3 = "some argument";// }functionBase(arg1,arg2,arg3){Inherited.apply(this,args1,arg2);this.arg3=arg3;// function3(){ not best practice// ...// }}Inherited.prototype.function1(){
...
}Inherited.prototype.function2(){
...
}Base.prototype.function3(){
...
}
Calling Objects of the classes
constinherited=newBase('val1','val2');constbase=newInherited('val1','val2','val3');inherited.function1();// calling function1inherited.function2();// calling function2base.function3();//calling function3 using base
Method Chaining
classBase{constructor(arg1,arg2){this.arg1=arg1;this.arg2=arg2;}function1(){
...
returnthis;}function2(){
...
returnthis;}}constbase=newBase('val1','val2');base.function1().function2();//will not work if 'this' is not returned by both function1 and function2 of the class Base