I'm trying to wrap my head around javascript modules, but I'm not sure how to split the module into additional submodules. I read that nested functions are not really a great idea because of performance, so how can I split a function in a module? For example, let's say I have the following module:
var Editor = {};
Editor.build = (function () {
var x = 100;
return {
bigFunction: function () {
}
};
})();
bigFunction applies only to Editor.build. Should I attach the smaller functions that make up the larger function for the prototype bigFunction object? I'm not even sure that this will make sense.
var Editor = {};
Editor.build = (function () {
var x = 100;
return {
bigFunction: function () {
bigFunction.smallFunction();
bigFunction.prototype.smallFunction = function(){ };
}
};
})();
Can someone please drop me in the right direction here? There is so much misleading information on the Internet, and it will be just as a concrete guide to how to deal with such modulation.
Thank.