Why is the first function (AKA parent function) only called once in this javascript closure code?
The parent function is called each time right? I believe that the console.log in the parent function should work each time, but it doesn't.
const Parent = (() => {
let value = 0;
console.log(`initial value: ${value}`);
return () => {
value += 1;
console.log(`${value}`);
};
})();
Parent(); //initial value: 0 , 1
parent(); // 1
parent(); // 2
parent(); // 3