Skip to content

Instantly share code, notes, and snippets.

@JasonDeving
Created March 20, 2016 03:21
Show Gist options
  • Save JasonDeving/70a2df67f41d3c119c7d to your computer and use it in GitHub Desktop.
Save JasonDeving/70a2df67f41d3c119c7d to your computer and use it in GitHub Desktop.
Simple library
var counter = (function() {
var i = 0;
return {
get: function() {
return i;
},
set: function(val) {
i = val;
},
increment: function() {
i++;
}
}
})();
console.log(counter.get());
counter.set(5)
counter.increment()
console.log(counter.get());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment