Hello friends today i am discuss about promise in java script. The Promise in java script is there is three condition first one is pending, reject or resolve.
There are three types of Promises property.
- Pending
- Fulfilled
- Rejected
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Promises in java script</title>
</head>
<body>
<script>
console.log("Check Promise Function");
function fun1() {
return new Promise(function(resolve, reject) {
setTimeout(() => {
const error = true;
if (!error) {
console.log("There is error");
} else {
console.log("this is reduclse");
}
console.log("Hello Set Time out function");
resoleve();
}, 1000);
})
}
fun1().then();
</script>
</body>
</html>