-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction.this.html
More file actions
62 lines (56 loc) · 1.03 KB
/
function.this.html
File metadata and controls
62 lines (56 loc) · 1.03 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
function Foo() {
this.name = 'foo';
this.has = el => {
return this.hasOwnProperty(el);
}
return this;
}
// console.log(Foo().name);
let foo = new Foo();
console.log(foo);
console.log(foo.has('name'));
console.log(this.name);
console.log(this.has);
console.log(this);
console.log(name);
function f1() {
setTimeout(() => {
console.log('f1');
}, Math.round(Math.random() * 500));
}
function f2() {
setTimeout(() => {
console.log('f2');
}, Math.round(Math.random() * 500));
}
function f3() {
setTimeout(() => {
console.log('f3');
}, Math.round(Math.random() * 500));
}
// f1();
// f2();
// f3();
new Promise(function(resolve, reject) {
resolve();
return f1(resolve);
})
.then(function(resolve) {
console.log(resolve)
return f2(resolve)
})
.then(function(resolve) {
resolve();
return f3(resolve)
})
</script>
</body>
</html>