Function factory scope
I have a JS factory function that return player objects.
let id = 0;
const playerFactory = (name) => {
id++;
return {name, id};
}
Is there a way to define and use id inside of playerFactory scope? Thanks!
I have a JS factory function that return player objects.
let id = 0;
const playerFactory = (name) => {
id++;
return {name, id};
}
Is there a way to define and use id inside of playerFactory scope? Thanks!