-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsole-1629527081415.log
66 lines (66 loc) · 1.46 KB
/
console-1629527081415.log
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const promise = doWork();
console.log('Promise is ',promise);
promise.then(data=>console.log(data)).catch(err=>console.log(err));
console.log('Code Ends ', promise);
function doWork(){
const promise = new Promise((resolve, reject)=>{
setTimeout(()=>{
var a = 100;
var b = 200;
var c = a + b;
resolve(c);
},7000);
});
return promise;
}
VM798:2 Promise is Promise {<pending>}
VM798:4 Code Ends Promise {<pending>}
undefined
VM798:3 300
promise;
Promise {<fulfilled>: 300}
const promise = doWork();
console.log('Promise is ',promise);
promise.then(data=>console.log(data)).catch(err=>console.log(err));
console.log('Code Ends ', promise);
function doWork(){
const promise = new Promise((resolve, reject)=>{
setTimeout(()=>{
var a = 100;
var b = 200;
var c = a + b;
resolve(c);
},7000);
});
return promise;
}
VM825:2 Promise is Promise {<pending>}
VM825:4 Code Ends Promise {<pending>}
undefined
VM825:3 300
const promise = doWork();
console.log('Promise is ',promise);
promise.then(data=>console.log(data)).catch(err=>console.log(err));
console.log('Code Ends ', promise);
function doWork(){
const promise = new Promise((resolve, reject)=>{
setTimeout(()=>{
var a = 10;
var b = 200;
var c = a + b;
if(c>=300){
resolve(c);
}
else{
reject("Error Value is Small ");
}
},7000);
});
return promise;
}
VM902:2 Promise is Promise {<pending>}
VM902:4 Code Ends Promise {<pending>}
undefined
VM902:3 Error Value is Small
promise
Promise {<rejected>: "Error Value is Small "}