JavaScript how to create persistent variable
First method is to return a function inside parent function. Note that the inner function has access to private property of parent.
const incr=(function(v) {
return function() {
return ++v;
}
})(100);
console.log(incr()); //101
consol...
loganlee.hashnode.dev1 min read