// Preferred way (for me)class x {}module.exports = x;or:
// ES5 "class" wayvar x = { functionName: function(){}}module.exports = x;or
// prototypesfunction something(){}something.prototype.constructor = function() {};module.exports = something;Notice the
module.exports = whatEver;it creates a module that is then not global, in the sense that everything is scoped to that module. You can then use something like require to require your modules in to other modules:
require('./whatEver')whatEver here is the name of the file containing the module.
These are es6 concepts How ever these are simple concepts to understand. They do require something like browserify with the bablify extension to compile in to es5 code. The code will be but ugly, but thats what github is for.
This is the true concept of modules.
If you want something like yanfly:
var Imported = Imported || {};Imported.YEP_BaseTroopEvents = true;var Yanfly = Yanfly || {};Yanfly.BTE = Yanfly.BTE || {};You create with objects with subjects that hold the information you want, how ever I have never seen this done in web development .... this:
var Yanfly = Yanfly || {};I've seen done and I tend to refactor the code to move on to the actual concept of "modules"