Skip to content

Instantly share code, notes, and snippets.

@d48
Created December 3, 2012 04:10
Show Gist options
  • Save d48/4192640 to your computer and use it in GitHub Desktop.
Save d48/4192640 to your computer and use it in GitHub Desktop.
to make javascript object method public
var hey = {};
(function() {
function woot() {
return 'hi';
}
function who() {
return 'me';
}
hey.woot = woot;
})();
// outputs: hi
console.log(hey.woot());
// outputs: who is not defined
console.log(who());
console.log(hey.who());
@d48
Copy link
Author

d48 commented Dec 3, 2012

pattern for making a method public and leaving others as private

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment