Skip to content

Instantly share code, notes, and snippets.

@ryo-utsunomiya
Created August 17, 2014 06:37
Show Gist options
  • Save ryo-utsunomiya/15e631b0ca1ffdcaa967 to your computer and use it in GitHub Desktop.
Save ryo-utsunomiya/15e631b0ca1ffdcaa967 to your computer and use it in GitHub Desktop.
javascript pattern: private member with object literal
var myobj;
(function () {
var name = 'my, oh my'; // private
myobj = {
// public
getName: function () {
return name;
}
}
}());
console.log(myobj.getName()); // 'my, oh my'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment