Skip to content

Instantly share code, notes, and snippets.

@zbigniewTomczak
Created February 19, 2013 14:03
Show Gist options
  • Save zbigniewTomczak/4986166 to your computer and use it in GitHub Desktop.
Save zbigniewTomczak/4986166 to your computer and use it in GitHub Desktop.
var myObject = function () {
var value = 0;
return {
increment: function (inc) {
value += typeof inc === 'number' ? inc : 1;
},
getValue: function() {
return value;
}
};
}();
myObject.increment();
console.log(myObject.value);
console.log(myObject.getValue());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment