📜  javascript代码示例的promise语法

📅  最后修改于: 2022-03-11 15:04:11.783000             🧑  作者: Mango

代码示例3
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"