-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.js
More file actions
83 lines (65 loc) · 1.6 KB
/
2.js
File metadata and controls
83 lines (65 loc) · 1.6 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// function f1(){
// if(true){
// console.log(x);
// var x='local'
// }
// }
// f1()
// ----------------------------
// var p = new Promise(function() {
// return "OK";
// });
// var p2 = p.then(function(data) {
// return data;
// });
// var p3 = p2.then(function(data) {
// return data + " Bye";
// });
// -------------------------------------------------
// var p = new Promise(function(resolve, reject) {
// setTimeout(function() {
// resolve("OK");
// }, 2000);
// });
// p.then().then(function(data) {
// console.log(data);
// });
// --------------------------------------
// var p = new Promise(function(resolve, reject) {
// setTimeout(function() {
// resolve("OK");
// }, 2000);
// }).then();
// var p2 = p.then(function(data) {
// return data + " Good";
// })
// --------------------------------------
// var p = new Promise(function(resolve, reject) {
// throw "Sorry";
// }).
// then((data) => console.log(data), (data) => data);
// ----------------------------------------
// var p = new Promise(function(resolve, reject) {
// resolve("OK");
// });
// var p2 = p.then(function(data) {
// return data;
// });
// var p3 = p.then(function(data) {
// return data;
// });
// console.log(p2);
// console.log(p3);
// console.log(p2 === p3);
// --------------------------------------
// var p = new Promise(function(resolve, reject) {
// resolve("OK");
// });
// var p2 = p.then(function(data) {
// return new Promise(function(resolve, reject) {
// resolve(`data is ${data}`);
// });
// });
// p2.then(function(data) {
// console.log(data);
// });