Within this discussion, we find several insightful perspectives worth exploring. I would like to contribute by presenting an approach that could be effective depending on how one defines the terms "parent function" and "child function."
In cases where the "child function" is contained within the "parent function," it is possible for the outer function's variable scope to remain active within the inner function, provided there are no conflicting variables declared within the inner function.
For instance, eliminating the parameter from the function in your example can yield the desired outcome. The mention of wuzi
within testWuzi
transforms into a closure, linking back to the wuzi
variable defined outside that function.
let wuzi = 20;
console.log(wuzi); //20 as expected
testWuzi(wuzi);
console.log(wuzi); //30
function testWuzi() {
wuzi = 30;
}