I'm a beginner in JS and I have a question about Promises.
Context: I have a basic promise with 3 callbacks:
const calcul = (num1, num2) =>{
return new Promise((resolve,reject) => {
const result = num1 * num2;
if(result > 20000){
resolve(result);
}else{
reject();
}
})
}
const fun1 = (result) => {
console.log('Result: ' + result);
};
const fun2 = () => {
console.log('Oups, error');
};
const fun3 = () => {
console.log('Oups, another error');
};
What is the difference between:
calcul(300,9).then(fun1).catch(fun2);
and
calcul(300,9).then(fun1,fun2);
What is the difference between:
calcul(300,90).then(fun1).catch(fun2).then(() => {console.log("FINALLY")});
and
calcul(300,900).then(fun1).catch(fun2).finally(() => {console.log("FINALLY")});
Thanks