Created
January 1, 2021 12:24
-
-
Save shahab570/9351c6287bbe0bbefbe4e58d082b46a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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