-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (46 loc) · 1.06 KB
/
index.js
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
function x(){
console.log("first");
function y(){
console.log("second");
function z(){
console.log("third");
}
return z;
}
return y;
}
x()
/* OUTPUT
first
ƒ y(){
console.log("second");
function z(){
console.log("third");
}
return z;
}
*/
x()()
/* OUTPUT
first
second
ƒ z(){
console.log("third");
}
*/
x()()()
/* OUTPUT
first
second
third
*/
// Bonus What is the output of this code
function x(){
for(var i = 1; i<=5; i++){
setTimeout(function(){
console.log(i)
},i * 1000)
}
}
x()
//https://www.jsv9000.app/?code=ZnVuY3Rpb24geCgpewogICAgZm9yKHZhciBpID0gMTsgaTw9NTsgaSsrKXsKICAgICAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uKCl7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKGkpCiAgICAgICAgfSxpICogMTAwMCkKICAgIH0KfQoKeCgpCgpmdW5jdGlvbiB5KCl7CiAgICBmb3IobGV0IGkgPSAxOyBpPD01OyBpKyspewogICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKXsKICAgICAgICAgICAgY29uc29sZS5sb2coaSkKICAgICAgICB9LGkgKiAxMDAwKQogICAgfQp9Cgp5KCkK