When there is a variable declaration inside the function body, which shares its name to a referenced identifier in default parameter expression, the function body should be wrapped into iife, otherwise the binding in default parameter scope will be shadowed by function body.
7 lines
94 B
JavaScript
7 lines
94 B
JavaScript
let x = "outside";
|
|
function outer(a = () => x) {
|
|
let x = "inside";
|
|
return a();
|
|
}
|
|
outer();
|