Consider the example:
let promiseA = new Promise((res, rej) => res(10));
let promiseB = new Promise((res, rej) => res(promiseA))
promiseB.then((resolvedVal) => console.log(resolvedVal)); //Outputs 10;
I expect resolvedVal to be promiseA, and not the resolved value of promiseA. Why is this not the case?
I understand this has something to do with the automatic "unwrapping" of promises, but I would like some insight on what exactly is happening under the hood.