forked from bharath12345/ADOBE_REACT_21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
promise.html
46 lines (41 loc) · 1.15 KB
/
promise.html
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>Promise API</h2>
<script>
function doTask() {
return new Promise( (resolve, reject) => {
setTimeout(() => {
resolve("Done!!!")
}, 1000)
})
}
function doAnotherTask() {
return new Promise( (resolve, reject) => {
setTimeout(() => {
resolve("Second Task!!!!!!")
}, 200)
})
}
function some() {
return "Hello";
}
// doTask().then(
// res => console.log(res),
// rej => console.log("Error :-(" + rej)
// );
// Promise.all([doTask(), doAnotherTask(), some() ]).then(
// results => console.log(results[0], results[1], results[2] )
// )
Promise.any([doTask(), doAnotherTask()]).then(
result => console.log(result )
)
console.log("End!!!")
</script>
</body>
</html>