const A = (function() { let id = 0; return function() { this.id = id++; } })(); const a = new A(); const b = new A(); console.log(a, b)