const foo = (x, y) {
try {
const result = x/y;
} catch(err) {
console.error(err.message);
return null;
}
return result;
};
function foo (x, y) {
try {
const res = x == y;
if(!res){
throw "res is false";
}
console.log('result:',res);
return res;
} catch(err) {
console.error('error:',err);
return err;
}
finally{
console.log('this code will be executed at all time');
return "haha";
}
console.log('that will never executed')
}
console.log( 'return1: ', foo( 4, 4 ) );
console.log( 'return2: ', foo( 10 / 3 / 4 / 5, 10 / 5 / 4 / 3 ) );