Last active
February 24, 2016 01:24
-
-
Save rndme/8b2b72ec2fb461884942 to your computer and use it in GitHub Desktop.
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
// uses arrow functions to define methods seperatly from data, like an alternative to .prototype. | |
var x=function(){ | |
return { // public methods: | |
get: ( )=> this.val, | |
set: (v)=> this.val=v, | |
}; | |
}.call({ // private state: | |
val: 902 | |
}); | |
x.get(); // 902 | |
x.val; // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment