Return to Snippet

Revision: 44525
at April 13, 2011 12:55 by housecor


Initial Code
var MODULE = function () {
	var privateVar = 4

	var privateMethod = function(arg) {
		//body here.
	};

	return {
		publicMethod : function(arg) { //so when you instantiate this module, you get a single method back. Could return a complex object via json instead here though that relies on the private state.
			privateMethod(arg);
		},
	};
}();

Initial URL
http://www.infoq.com/presentations/JavaScript-Functions

Initial Description


Initial Title
Javascript encapsualtion via the module pattern

Initial Tags


Initial Language
JavaScript