let a=new A();
let b=A();
How can I write the function constructor in such a way that the following values are returned?
console.log(a) \\ return 1
console.log(a) \\ return 2
console.log(a) \\ return 3
Following is my code
function A() {
this.count=1;
return function() {
return this.count++;
}
}
It works using closures but only when console.log(a()) is called 3 times and not console.log(a).