Here you can have 2 different classes:
var Fun = function(){ };
Fun.prototype.f1 = function(){
console.log ( "Help FUN");
return this;
};
Fun.prototype.f2 = function(){
console.log ( "Print FUN");
return this;
};
Then define the property Funin Main:
var Main = function(){ };
Main.prototype.fun = new Fun();
or how:
var Main = function(){
this.fun = new Fun();
};
Then you can use it like:
var main = new Main();
main.fun.f1().f2();
or
main.fun.f2().f1();
source
share