/ Published in: JavaScript
URL: http://www.infoq.com/presentations/JavaScript-Functions
Expand |
Embed | Plain Text
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); }, }; }();
You need to login to post a comment.
