Create a gist now

Instantly share code, notes, and snippets.

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