Skip to content

Instantly share code, notes, and snippets.

@fernandezpablo85
Forked from bryanroth/gist:645573
Created October 25, 2010 19:41
Show Gist options
  • Save fernandezpablo85/645580 to your computer and use it in GitHub Desktop.
Save fernandezpablo85/645580 to your computer and use it in GitHub Desktop.
var objectCreator = function () {
var value = 0;
return {
increment: function (inc) {
value += typeof inc === 'number' ? inc : 1;
},
getValue: function () {
return value;
}
};
}
var myObject = objectCreator();
@sheryarshirazi
Copy link

JavaScript Closure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment