-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpromices.js
More file actions
49 lines (43 loc) · 1 KB
/
Copy pathpromices.js
File metadata and controls
49 lines (43 loc) · 1 KB
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
47
48
49
/*Promice chaining*/
// function getData(dataId){
// return new Promise((resolve,reject)=>{
// setTimeout(()=>{
// console.log("Data: ",dataId);
// resolve("Sucess");
// },3000);
// });
// }
// getData(1).then((res)=>{
// console.log(res);
// getData(2).then((res)=>{
// console.log(res);
// })
// })
/*async Await*/
// function getData(dataId){
// return new Promise((resolve,reject)=>{
// setTimeout(()=>{
// console.log("Data :",dataId);
// resolve("Sucess");
// },2000);
// })
// }
// async function deserveData() {
// await getData(1);
// await getData(2);
// await getData(3);
// }
/*IIFE*/
function getData(dataId){
return new Promise((resolve,reject)=>{
setTimeout(()=>{
console.log("Data :",dataId);
resolve("Sucess");
},2000);
})
}
(async function() {
await getData(1);
await getData(2);
await getData(3);
})();