Created
June 4, 2014 21:00
-
-
Save mauriciosoares/e5cba1151013db898bdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Constr = (function() { | |
var id = 0; | |
function cl() { | |
this.id = id += 1; | |
} | |
cl.prototype.getId = function() { | |
return this.id; | |
} | |
return cl; | |
} ()); | |
var item1 = new Constr(); | |
var item2 = new Constr(); | |
item1.id; // 1 | |
item1.getId; // 1 | |
item2.id; // 2 | |
item2.getId; // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment