Test your Javascript skills with our fun Javascript test!

Posted on: August 9th, 2017 by Dean North

Javascript can be “fun” sometimes. We put together this “test” to highlight to new Javascript developers some of the weird things that Javascript can do when used in particular ways. This isn’t really a serious test, but it can be fun to take if you think you know a lot about Javascript to see if you can get 100%. Each question is a snippet of Javascript and all you need to do is select what the console output will be. You can copy paste the question into your chrome console and execute it to cheat if you like, but I would recommend that you give it a full run through yourself first. Happy testing!

Please select what will appear in the console for each question. If other, please specify.

You scored out of 16! Feel free to check out all the correct answers below.

Dean North

Dean North

Dean founded Bespoke Software Development Company – Atlas Computer Systems Limited and is our technical consultant (aka technical wizard).

Want to stay up to date with the latest software news, advice and technical tips?

  • hansgman

    who still works primarily with vanilla JS in 2017? typescript yo!

  • Author, check the answer for QUESTION 4.

    • Ditto

    • MaxArt

      Indeed, the answer actually depends on the execution context.

    • Archie

      On both Chrome 60 and node.js 8.2.1 (which window is replaced by “this”), answer is “B”

    • Dean North

      The answer to question 4 is in fact undefined. This question is designed to show the results of hoisting. Unfortunately chrome’s developer console has undergone some changes in the last few months which mean that it no longer hoists variable declarations like it should. You can see the results of hoisting in question 4 if you run the script in the page rather than the console like in this fiddle https://jsfiddle.net/n4x1fu1z/. Here you will see undefined correctly being reported in the console.

      • OMG! Did you know what jsfiddle wrap your code in window.onload()?

        • Dean North

          You’re right it does! I thought you had to opt in for that before.

  • Nice!

  • MaxArt

    I botched #6 because I was too lazy to type it all…

  • chris-l

    On question 6, my answer was “function () { return ‘A’; }”. It was marked as wrong because it was supposed to be “function(){return ‘A’;}”

    That is, the same answer, but with different spacing. Also, ditto with question 4.

  • Rainforce Quintus-Decimus

    Professional dev here, did this test as a joke: The fact that you have to type the answer perfectly correct and that you only give A/B/C/etc. options on questions with numeric data makes this an exceptionally bad test. (not to mention execution environment)

  • Rico Alexander

    Will we get an explanation of the answers?