Can someone explain to me why I can access "m" in global scope in the following scenario:
const a = {m: 'beeb'};
const magic = function topLevel () {
function lowerLevel() {
if ({m} = a ) {
console.log('in lowerLevel-func: ', m);
}
}
lowerLevel();
}
magic();
console.log('in global', m);
and here is JSFiddle
Edit: Just to clarify, I am not using this anywhere, I was just wondering how it was possible. Now I know, thanks!