-
-
Save olopsman/5ea4fe771d533048f9a3cd4cd03e9f17 to your computer and use it in GitHub Desktop.
Sharing JavaScript Code Across Components in Salesforce, javascript closure pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window._counter = (function() { // this is attached to the window object thus this is a namespace variable | |
var value = 0; // private | |
return { //public API | |
increment: function() { | |
value = value + 1; | |
return value; | |
}, | |
getValue: function() { | |
return value; | |
} | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment