Perfection Kills

by kangax

Exploring Javascript by example

← back 933 words

Javascript quiz. ES6 edition.

Remember that crazy Javascript quiz from 6 years ago? Craving to solve another set of mind-bending snippets no sensible developer would ever use in their code? Looking for a new installment of the most ridiculous Javascript interview questions?

Look no further! The "ECMAScript Two Thousand Fifteen" installment of good old Javascript Quiz is finally here.

The rules are as usual:

  • Assuming ECMA-262 6th Edition
  • Implementation quirks do not count (assuming standard behavior only)
  • Every snippet is run as a global code (not in eval, function, or module contexts)
  • There are no other variables declared (and host environment is not extended with anything beyond what's defined in a spec)
  • Answer should correspond to exact return value of entire expression/statement (or last line)
  • "Error" in answer indicates that overall snippet results in a compile or runtime error
  • Cheating with Babel doesn't count (and there could even be bugs!)

The quiz goes over such ES6 topics as: classes, computed properties, spread operator, generators, template strings, and shorthand properties. It's relatively easy, but still tricky. It tries to cover various ES6 features — a little bit of this, a little bit of that — but it's certainly still only a tiny subset.

If you can think of other silly riddle ideas to break one's head against, please post them in the comments. For a slightly harder version, feel free to explore some of the tests in our compat table or perhaps something from TC39 official test suite.

Ready? Here we go.

  1.  

  2.  

  3.  

  4.  

  5.  

  6.  

  7.  

  8.  

  9.  

  10.  

  11.  

  12.  

  13.  

Here be quiz result

I hope you enjoyed it. I'll try to write up an explanation for these in the near future.

Vote on Hacker News

Did you like this? Donations are welcome

comments powered by Disqus