Can someone please explain the code below? I'm confused about the role of
return f();
Does
return f();
call the methodf
and return the result? (i.e. the return off
)Does
return f();
return an object?
If I change return f();
to just f();
then checkscope = undefined
var scope = "global scope"; // A global variable
function checkscope() {
var scope = "local scope"; // A local variable
function f() { return scope; } // Return the value in scope here
return f();
}
checkscope() // => "local scope"