consider this:
function something() {
let a = { "a": "val", "b": [{ "c": "val" }] };
console.log(a);
a.b = a.b.map(f => ({ "test": "something" }));
}
In the above, I expect the console.log to be executed before the map function and so any mapping/transformation done by the map function shouldn't affect the value of console.log but it's not the case.
Map function modifies the value of the console.log even if it is called before map function. Here is what is logged:
so b actually got changed by map! however if I comment the map function, it works fine. A bit confused here. does map hoists it's changes or something fundament is that what I am missing here?