Last active
August 20, 2018 20:36
-
-
Save DmitrySoshnikov/45936c1a796884e0ac54026b7fdfac20 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* JS scoping, and this property resolutions rules in ES7/ES8. | |
* | |
* Quiz: x is gone, and x is everywhere! | |
* | |
* Help find Xs! What's the output? | |
*/ | |
let x = 1; | |
({ | |
x: 2, | |
run() { | |
(new class X { | |
x = 3; | |
static x = 4; | |
getX = () => { | |
return this.x; | |
}; | |
static getX = () => { | |
return this.x; | |
}; | |
exec() { | |
console.log(X.getX() + this.getX()); | |
} | |
}).exec(); | |
} | |
}).run(); // ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what will be the answer? 2+2 = 4?