-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputQuestion.js
More file actions
77 lines (59 loc) · 971 Bytes
/
Copy pathOutputQuestion.js
File metadata and controls
77 lines (59 loc) · 971 Bytes
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
// 1. =====================
var bar=1
function foo(){
return this.bar++
}
const a={
bar:10,
foo1:foo,
foo2:function(){
return foo()
}
}
console.log(a.foo1.call())
console.log(a.foo1())
console.log(a.foo2.call())
console.log(a.foo2())
// Output 1,10,2,3
// 2. ===========================
console.log(1)
async function async1(){
console.log(2)
await async2()
console.log(3)
}
async function async2(){
console.log(4)
}
async1()
setTimeout(()=>{
console.log(5)
})
new Promise((resolve,reject)=>{
console.log(6)
resolve()
}).then((res)=>console.log(7))
console.log(8)
// Output
// 1
// 2
// 4
// 6
// 8
// 3
// 7
// 5
// 3. ===================
for(var i=0;i<10;i++){
setTimeout(()=>{
console.log(i)
},0)
}
// Output- 10 10 10 10 10 10 10 10 10 10
// 4. =======================
for(let i=0;i<10;i++){
setTimeout(()=>{
console.log(i)
},0)
}
// Output- 0 1 2 3 4 5 6 7 8 9