What does this log when a default parameter's closure and the function body both use x?
var x = "global";
function f(read = () => x) {
var x = "body";
return read();
}
function g(x = "param", read = () => x) {
var x = "body";
return [x, read()];
}
console.log(f());
console.log(g());
The answer
Work out every line it logs, in order. Then check.
Checking your sign-in…