-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 723 Bytes
/
Copy pathscript.js
File metadata and controls
26 lines (23 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
A JavaScript Promise contain two type of code:
1. "Consuming Code "
2. "Producing Code" : It contains the result and should call one of the callbacks
⏩ it will callback the error or the succes
Understand the following Program how to use promise
*/
let textOne = document.getElementById('textOne');
function Display(some) {
textOne.innerHTML = some;
}
let myPromise = new Promise(function(Resolve, Reject) {
let x = 0;
if (x == 0) {
Resolve("Open script.js file and console for better Understanding !");
} else {
Reject("Error just Occured");
}
})
myPromise.then(
function(success) { Display(success) },
function(error) { Display(error) }
);