async, await 1
// function mydisplay(mal){
// console.log(mal)
// }
// const mypromic = new Promise(function executor(resolve,reject){
// let x=2;
// if (x==0){
// console.log("resole part")
// resolve("okk")
// }
// else{
// reject()
// }
// })
// mypromic.then(
// function one(value){
// mydisplay(value);
// }).catch(function two(){
// console.log("eror")
// }
// )
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
const mypromic = new Promise(function executor(resolve,reject){
let x=0;
if (x==0){
console.log("resole part")
resolve("okk")
}
else{
reject("Error hoye galo")
}
})
// mypromic.then(
// function one(value){
// mydisplay(value);
// }).catch(function two(){
// console.log("eror")
// }
// )
async function some(){
try{
const one= await mypromic;
console.log(one)
}
catch(err){
console.log(err)
}
}
some()
Comments
Post a Comment