Created
August 17, 2014 06:37
-
-
Save ryo-utsunomiya/15e631b0ca1ffdcaa967 to your computer and use it in GitHub Desktop.
javascript pattern: private member with object literal
This file contains hidden or 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
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