What will be the order of the following code:
Promise.resolve(1) .then(() => 2) .then(3) .then((value) => value * 3) .then(Promise.resolve(4)) .then(console.log);
Select one of the following:
The output will be: 6
Promise.resolve(1) → Initial value is 1.then(() => 2) → Returns 2.then(3) → Ignored because 3 is not a function, passes previous value 2.then((value) => value * 3) → 2 * 3 = 6.then(Promise.resolve(4)) → Ignored because it's not a function, passes previous value 6.then(console.log) → Prints 6Key points:
.then() receives a non-function (like 3 or Promise.resolve(4)), it ignores that handler and passes the previous value throughPromise.resolve(1)
.then(() => 2)
.then(3)
.then((value) => value * 3)
.then(Promise.resolve(4))
.then(console.log);