Looking at this simple code which uses Lazy Expressions:
var x = 1;
function foo(x = 2, f = () => x) {
var x = 5;
console.log(f())
}
foo()
The output here is 2.
I must say that I thought it should output 5.
However - this would've been logical if f was closing over the parameter list scope - if it had a scope.
Because looking at this other example (which a bit related) :
var x = 5;
var f = function() {
return x;
}
x = 1
f();
console.log(x)
This will output 1. (Which is the expected result.).
Question
What's actually going here with the parameter list scope ? is there any scope here at all ?(at the parameter list)
I didn't find scope related info in the docs.