Skip to content

Instantly share code, notes, and snippets.

@andrew8088
Created July 29, 2011 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrew8088/1114686 to your computer and use it in GitHub Desktop.
Save andrew8088/1114686 to your computer and use it in GitHub Desktop.
This little JavaScript object is a quick example for a Nettuts+ tutorial.
var MyObject = function (state) {
this._state = state;
}
MyObject.prototype.setState = function (state) {
this._state = state;
};
MyObject.prototype.addState = function (state) {
if (typeof this._state === "string") {
this._state = [this._state, state];
} else {
this._state.push(state);
}
};
MyObject.prototype.getState = function () {
return this._state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment