-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathepisode4.js
More file actions
43 lines (36 loc) · 685 Bytes
/
episode4.js
File metadata and controls
43 lines (36 loc) · 685 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
(function foo() {
var a = 3;
console.log(a);
})();
console.log(a)
// 3.31
setTimeout(function () {
console.log("I waited 1 second!");
}, 1000);
setInterval(function timeoutHandler() {
console.log("I waited 1 second!")
}, 1000);
var a = 2;
(function foo() {
var a = 3;
console.log(a);
})();
console.log(a)
// undefined covered
undefined = true;
(function IIFE(undefined) {
var a;
console.log(a)
if (a === undefined) {
console.log("Undefined is safe here!")
}
})
// IIFE window global
var a = 2;
(function IIFE(def) {
def(window)
})(function def(global) {
var a = 3;
console.log(a) // 3
console.log(global.a) // 2
})