I want the function sayOhai to say "ohai" using the defined var. Assumed i do not want to change the parameter name of sayOhai, how can i access foo's value within sayOhai?
You simply can't. The var foo
is shadowed by the inner function parameter with the same name.