📅  最后修改于: 2022-03-11 15:04:11.783000             🧑  作者: Mango
let promise = new Promise(function(resolve, reject){
try{
resolve("works"); //if works
} catch(err){
reject(err); //doesn't work
}
}).then(alert, console.log); // if doesn't work, then console.log it, if it does, then alert "works"