This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Global execution context (not inside a function) | |
this === window // logs true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo; // 'bar' | |
window.foo; // 'bar' | |
this.foo; // 'bar' | |
(window.foo === foo && this.foo === foo && window.foo === this.foo) // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a() { | |
// some code | |
b(); | |
// some more code | |
} | |
function b() { | |
// some code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a() { | |
// some code | |
b(); | |
// some more code | |
} | |
function b() { | |
// some code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a() { | |
function b() { | |
console.log(foo); // logs 'bar' | |
} | |
var foo = 'bar'; | |
b(); | |
} | |
a(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a() { | |
var foo = 'bar'; | |
b(); | |
} | |
function b() { | |
console.log(foo); // throws ReferenceError: foo is not defined | |
} | |
a(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a() { | |
function b() { | |
function c() { | |
console.log(foo); | |
} | |
c(); | |
} | |
var foo = 'bar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myArrowFunction = () => { | |
console.log(this === window); | |
}; | |
class MyClass { | |
constructor() { | |
myArrowFunction(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass { | |
constructor() { | |
const myArrowFunction = () => { | |
console.log(this === window); | |
}; | |
myArrowFunction(); | |
} | |
} | |
var myClassInstance = new MyClass(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a() { | |
// ... | |
} |
OlderNewer