See this
let foo = 'outer';
function bar(func = x => foo) {
let foo = 'inner';
console.log(func());
}
bar(); //outer
I want to know why the output is 'outer' rather than 'inner',I know js is lexica scope, This output makes me feels like that the function 'x => foo' is defined out of Function bar
Aucun commentaire:
Enregistrer un commentaire