I am facing a weird issue while doing console.log of variable inside an async function. see below code -
var blackbox = async function (){
return Promise.resolve({a: 1, b: {c:[2,3], d: 4}});
}
var nester = async function (){
return blackbox().then(res => {console.log(res); console.log(res.b.c);return res;});
}
var wrapper = async function (){
return nester().then(res => {
res.b.c = []; return res;
});
}
wrapper();
I ran this in google chrome and saw the output to be the below screenshot
to explain - first console.log should have c NOT as empty. Moreover, even if it was to be empty why is the second log just below it shows c is, in fact, not empty.