Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Last active August 20, 2018 20:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DmitrySoshnikov/45936c1a796884e0ac54026b7fdfac20 to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/45936c1a796884e0ac54026b7fdfac20 to your computer and use it in GitHub Desktop.
/**
* 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(); // ?
@Areks
Copy link

Areks commented Sep 13, 2016

what will be the answer? 2+2 = 4?

@arash-hacker
Copy link

screen shot - - at
screen shot - - at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment