Tuesday, February 9th, 2010

Think You Know Javascript? Try this Quiz!

Category: JavaScript

<>p>If you know you think you know your objects from your arrays and your null from your undefined, here’s a quiz for you from Perfection Kills.

I was recently reminded about Dmitry Baranovsky’s Javascript test, when N. Zakas answered and explained it in a blog post. First time I saw those questions explained was by Richard Cornford in comp.lang.javascript, although not as thoroughly as by Nicholas.

I decided to come up with my own little quiz. I wanted to keep question not very obscure, practical, yet challenging. They would also cover wider range of topics.

There are fourteen questions in all, starting here:

    (function(){ 
      return typeof arguments;
    })();

  • “object”
  • “array”
  • “arguments”
  • “undefined”
  • Related Content:

    Posted by Michael Mahemoff at 3:49 am
    6 Comments

    +++--
    3.8 rating from 35 votes

    6 Comments »

    Comments feed TrackBack URI

    There’s some pretty good infos on theses quizz / explanations.
    Worth reading : you’ll certainly learn something.

    Comment by ywg — February 9, 2010

    neat quiz, but borders on pedantic rather than useful. I’m not sure I’d hold it against a dev if they couldn’t tell you what the result of the following is:

    var x = [typeof x, typeof y][1];
    typeof typeof x;

    Comment by thnkfstr — February 9, 2010

    @thnkfstr I’ll explain in the upcoming post (that also provides and explains answers) why this quiz is useful. As far as `typeof typeof …`, you really don’t even need to know what happens in first line. `typeof` always returns string (even for host objects), so `typeof typeof …` obviously always results in “string” ;)

    Comment by kangax — February 9, 2010

    it is a shame that the programming language that may well be the best-deployed programming language of all times is full of unscrutinable reasoning, unreasonable plumbing, and outright bugs, on top of an interpretation of object-orientation that requires an expert to avoid the most obvious pitfalls.

    the language that drives billion of webpages should be easy to learn, easy to grasp, and easy to read. javascript’s score on each dimension is appalling. at least it seems to have become rather fast of late.

    Comment by loveencounterflow — February 9, 2010

    @kangax – Fascinating stuff, but I too think it borders on the pedantic. I also don’t think a good developer is only someone who knows all the answers to these: people on top of all these answers aren’t writing javascript themselves – they’re writing blog posts about how well they know it (or how awesome they are)! :)

    Comment by sixtyseconds — February 10, 2010

    For all the people who say the questions are pedantic, I agree – but I would also say that misses the point. Each question focuses on an important characteristic or quirk of JS. Surely knowing these is important.

    Comment by hymanroth — February 10, 2010

    Leave a comment

    You must be logged in to post a comment.