Skip to content

Instantly share code, notes, and snippets.

@jacopotarantino
Created March 5, 2018 18:47
Show Gist options
  • Save jacopotarantino/cbe310d0042527cddc497ce9c709e7a3 to your computer and use it in GitHub Desktop.
Save jacopotarantino/cbe310d0042527cddc497ce9c709e7a3 to your computer and use it in GitHub Desktop.
Impossible JavaScript Question
/* what do each of these statements return?
(assume that they are evaluated individually but in order.)
*/
const foo = 'asdf'; //=> ?
foo.bar = 12345; //=> ?
foo; //=> ?
foo.bar; //=> ?
Object.getOwnPropertyNames(foo); //=> ?
@jacopotarantino
Copy link
Author

@EionRobb - I hadn't even thought about strict mode yet. Good catch!
@mgd020 - Shits and giggles lol. This actually came up because of production code so somebody did it in production.
@gkaykck - Haha. Well done ;). I absolutely don't expect people to know this stuff by heart. That's why it's such a weird challenge. This isn't stuff that you should know because you should never be doing this nonsense to begin with.

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