Separate a module into smaller parts The file is quite long, 1000 LOC so I want to separate it into smaller files.

https://github.com/anvoz/world-js/blob/v1.0/js/world.core.js

Here is a brief version of the code:

(function(window, undefined) {
    var WorldJS = window.WorldJS = function() {
        // WorldJS Constructor
        this.nextSeedId = 1;
        this.Statistic = { population: 0 };
        this.Knowledge = {
            completed: [],
            gain: function(world) { /* ... */ }
        };
    }
    WorldJS.prototype.someMethods = function() {};

    var Seed = WorldJS.prototype.Seed = function() {
        // Seed Constructor
    };
    Seed.prototype.someMethods = function() {};
})(window);

// Create a world
var world = new WorldJS();
// Create a seed
var seed = new world.Seed();


Seems like I was right with the Seed class. So I can put Seed in a new file. Like this:

(function(window, undefined) {
    var WorldJS = window.WorldJS;
    var Seed = WorldJS.prototype.Seed = function() {
        // Seed Constructor
    };
    Seed.prototype.someMethods = function() {};
})(window);


How can I put the Knowledge property to a new file? Is it a good practice if I change Knowledge to a class just like the Seed class and use a new lowercase property to hold data like this:

world.knowledge = new world.Knowledge();
I don't see the advantage of adding Seed and Knowledge into the prototype of World (unless you've got more code to tell me otherwise). If you don't need anything from the instance at all, then you don't need them in the instance. You can put them like static members instead.

With that, you can do what jQuery did. jQuery's jQuery and $ point to a constructor function that builds jQuery objects. That's why you can do jQuery() and $(). 

But in JS, functions are objects and like any other object, you can add properties. It's the same reason why you can also do jQuery.each or $.each. Basically they made their constructor their namespace as well.

So you can do the following to World:

(function(window){

  var World = window.World = function(){/*World constructor code*/};

  World.prototype.someFn = function(){/*...*/};

}(window));


And like how non-instance jQuery plugins extend (and yes, you can place this in another file. Just make sure the World library is loaded first):

(function(World){

  //This part would be synonymous to $.somePlugin = function(){...}
  var Seed = World.Seed = function(){/*Seed constructor code*/};

  Seed.prototype.someFn = function(){/*...*/};

}(World));


To use them:

var myWorld = new World();        //Using World as a constructor
var mangoSeed = new World.Seed(); //Using World to access the Seed constructor