[url=http:/civis/viewtopic.php?p=25446297#p25446297:biq9geq0 said:EmeraldArcana[/url]":biq9geq0]Hey all. I'm doing some Javascript work (it's an educational game). I've been doing most of my stuff using the Module pattern, which looks something like the following:
Code:var MyModule = (function() { var exports; exports.dance = function(type) { return type; } return exports; })();
But I occasionally see in this codebase I'm working on some other pattern that I don't know the name of:
Code:var MyOtherModule = { process: function(text) { return " }, startup: function() { return "Start up"; }, shutdown: function() { return "Shut down"; } }
One thing I figured out was that the second method doesn't allow you to use methods in the other methods (ex: I can't call shutdown within process) without some weird magic that I haven't figured out yet.
Code:
process: function(text) { this.shutdown(); return "Processing"; }