Skip to content

Instantly share code, notes, and snippets.

@rexcfnghk
Last active November 4, 2018 01:48
Show Gist options
  • Save rexcfnghk/4aae7688e45439a1066d09efba20ecf9 to your computer and use it in GitHub Desktop.
Save rexcfnghk/4aae7688e45439a1066d09efba20ecf9 to your computer and use it in GitHub Desktop.
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