public
Created

This little JavaScript object is a quick example for a Nettuts+ tutorial.

  • Download Gist
MyObject.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.