Which two promises are rejected?

A developer is wondering whether to use, Promise.then or Promise.catch, especially when a Promise throws an error?

Which two promises are rejected?

Which 2 are correct?
A . Promise.reject(‘cool error here’).then(error => console.error(error));
B . Promise.reject(‘cool error here’).catch(error => console.error(error));
C . New Promise((resolve, reject) => (throw ‘cool error here’}).catch(error => console.error(error)) ;
D . New Promise(() => (throw ‘cool error here’}).then(null, error => console.error(error)));

Answer: B,C

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments