Skip to content

Instantly share code, notes, and snippets.

@shahab570
Created January 1, 2021 12:24
Show Gist options
  • Save shahab570/9351c6287bbe0bbefbe4e58d082b46a1 to your computer and use it in GitHub Desktop.
Save shahab570/9351c6287bbe0bbefbe4e58d082b46a1 to your computer and use it in GitHub Desktop.
const new_car = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("This is the car.Enjoy!!!");
}, 3000);
});
new_car
.then((value) => {
alert(value); //ths code runs because promise resolves
})
.finally(() => {
alert("result is ready"); //it always runs
})
.catch((error) => {
alert(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment