If I create a new promise object and return a new promise object inside like this, p1 will keep pending.
var p1 = new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
resolve(1);
});
});
But if I chain the inner new promise with a then() and call revolve, the outer new promise p1 will get resolved.
var p1 = new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
return resolve(1);
}).then(data => resolve(123));
});
It seems that the resolve() in the .then() actually resolve p1. Can anyone tell me what is happening here? Why can't the first p1 be resolved and why the second p1 is resolved?