Skip to content

Instantly share code, notes, and snippets.

@arkumish
Created September 26, 2020 08:07
Show Gist options
  • Save arkumish/52aae5420e147f1f36d264fd1b0ad96f to your computer and use it in GitHub Desktop.
Save arkumish/52aae5420e147f1f36d264fd1b0ad96f to your computer and use it in GitHub Desktop.
Promises in JS
// In real life, you make promise for doing something. Based upon ur success and failure of ur promise, u have to don certain task.
// same way, Promises work in JS, check following example
let p = new Promise((resolve,reject)=>{
let a=true;
if(a){resolve("success")}
else{reject("failed")}
})
p.then((message)=>{
//this is success case
console.log(message) //output : success
}).catch((message)=>{
//this is fail case
console.log(message) //output : failed
})
function handleMyinfo{
return new Promis((resolve,reject)=>{
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment