Output: Promise executor logs, calls resolve twice, then reject
MediumP2Output
What does this code print?
1const p = new Promise((resolve, reject) => {2 console.log('executor');3 resolve('first');4 resolve('second');5 reject(new Error('late'));6 console.log('after settle calls');7});8p.then(9 (v) => console.log('then', v),10 (e) => console.log('catch', e.message)11);12console.log('sync end');
Saved automatically
One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).
Hints
Saved automatically