I am new to promise and I am wondering which is the best practice with native Promise (NodeJs).
I put some code below to better understand the question:
Code A
function foo(condition) {
return new Promise((resolve, reject) => {
if(condition){
resolve('Promise result!');
} else {
reject('Promise rejected!');
}
});
}
Code B
function foo(condition) {
return new Promise((resolve, reject) => {
if(condition){
return resolve('Promise result!');
} else {
return reject('Promise rejected!');
}
});
}
In solution B, I add the return statement.
Is it useful?
Which are the difference between Code A and Code B? If any?