Last active
November 4, 2018 01:48
-
-
Save rexcfnghk/4aae7688e45439a1066d09efba20ecf9 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
function MyObject() { | |
this.state = 1; | |
} | |
MyObject.prototype.getState = function () { | |
return this.state; | |
}; | |
MyObject.prototype.increment = function () { | |
this.state++; | |
}; | |
var obj = new MyObject(); | |
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