What is the output of the following? const p = new Promise(resolve => resolve(1)); p.then(v => v * 2).then(v => console.log(v));

JavaScript Developer Medium

JavaScript Developer — Medium

What is the output of the following? const p = new Promise(resolve => resolve(1)); p.then(v => v * 2).then(v => console.log(v));

Key points

  • The Promise resolves to 1
  • The value is multiplied by 2 in the first .then() block
  • The final result is 2 being logged to the console

Ready to go further?

Related questions