I was wondering if there was some way to obtain the value of a variable that has been captured by a nested function, from outside of that said function. A little tricky to explain in words so here's what I'm trying to achieve:
function counter(){
let count = 0;
return function counterIncrementer(){
++count;
}
}
function someReceiever(counterIncrementer){
// From here, somehow access the value of count captured by
// counterIncrementer.
// -> Without modifying the counter/returned counterIncrementer function
// before runtime
}
someReceiever(counter())
Thanks !