oop - Javascript child objects -


this question has answer here:

my javascript app getting big , want split on multiple files. have wrapped

var myapp = function() { /*functions , variables here*/ } 

and want this, each child object in different file:

var myapp = new function() { }  myapp.childobject1 = new function() {      this.func= function() {         console.log('hello');     } }  myapp.childobject2 = new function() {      this.func= function() {         console.log('world');     } }  myapp.childobject1.func(); myapp.childobject2.func(); 

it works, i'm wondering if correct way it.

thank answers. found article http://www.adequatelygood.com/javascript-module-pattern-in-depth.html helpful.

that should work fine. find pattern , go it.

http://toddmotto.com/mastering-the-module-pattern/

one of first links found searching javascript module patterns


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -