Skip to content

Instantly share code, notes, and snippets.

@vestige
Created November 27, 2012 13:42
Show Gist options
  • Select an option

  • Save vestige/4154276 to your computer and use it in GitHub Desktop.

Select an option

Save vestige/4154276 to your computer and use it in GitHub Desktop.
562.js
var Gadget = (function() {
var counter = 0,
NewGadget;
NewGadget = function () {
counter += 1;
};
NewGadget.prototype.getLastId = function () {
return counter;
};
return NewGadget;
}());
var iphone = new Gadget();
iphone.getLastId();
var ipod = new Gadget();
ipod.getLastId();
var ipad = new Gadget();
ipad.getLastId();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment