Last active
November 4, 2018 01:51
-
-
Save rexcfnghk/8b1df86016b6b758774a9d1f312df05c to your computer and use it in GitHub Desktop.
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 makeObject = function () { | |
var s = 1; | |
return { | |
getState: function() { return s; }, | |
increment: function() { | |
s++; | |
} | |
}; | |
}; | |
var obj = makeObject(); | |
console.log(obj.getState()); // 1 | |
obj.increment(); | |
console.log(obj.getState()); // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment