/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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); }, }; }();
URL: http://www.infoq.com/presentations/JavaScript-Functions
Comments
