Skip to content
Front-End Developer tech screen quiz
Pull request Compare This branch is 1 commit ahead, 87 commits behind nathansmith:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

JavaScript Quiz

Note: The intent of this quiz isn't to be a brain-buster. It is meant for recruiters to present to front-end developer candidates. The intent to weed out some "Just use jQuery" applicants, but allow those that know JavaScript to pass fairly easily.

Intro Questions

  1. When might comparative type coercion occur? How would you avoid it? How would you change a "falsey" or "truthy" value into a real boolean?

  • When using ==, type coercion may occur.
  • To avoid comparative type coercion, use ===.
  • To change a "falsey"/"truthy" into its real value, use !!. For example: !!

  1. Describe how variable scope works. Explain how to create a closure, using a self-executing anonymous function (also called IIFE: immediately-invoked function expression).

  2. Explain briefly how prototypical inheritance differs from class-based, "classical" inhericance.

  3. Describe how the "module pattern" works. Explain how the "revealing module pattern" expands upon it.

  4. How does a client-side MVC (or MVVM) approach work? What is your preferred MV* JS framework?

Additional Questions

  1. Why do these yield different results?

    "1" + 2 +  3 ; // Equals "123"
     3  + 2 + "1"; // Equals "51"
     3  + 2 +  1 ; // Equals 6
  2. Why is 0.3 not the result of the following addition? How do you work around this bug?

    0.1 + 0.2; // Equals 0.30000000000000004
  3. Describe how variable hoisting works, and how to account for it.

  4. How do these differ?

    function foo(){}
    // versus
    var foo = function(){};
  5. When would you use *.call()? — When would you use *.apply()?

  6. Explan how to check if a variable is an array.

  7. In the following example, what is foo aliased to? (Hint: It is what this means.)

    (function(foo) {
      // What is 'foo' aliased to?
  8. In JavaScript (and the DOM), variables we consider universal are actually mutable: window, document, undefined. How would you write code to ensure these were predictably available for use? Meaning, assuming someone had injected this code, how would you work around it? (Hint: See the previous question.)

    var window = '';
    var document = 0;
    var undefined = true;
  9. In one line of code, how you would clone (make a copy of) an array?

  10. What is the difference between setInterval and setTimeout? — Bonus: What is the lowest cross-browser increment that each can accurately use?

  11. Explain how delete works. What types of things cannot be deleted?

  12. Describe how event delegation works, and when you should use it to handle UI interaction.

  13. What does this snippet of code do?

    var foo = bar ? bar : 0;
  14. When might you write something like this, and what is it shorthand for?

    foo &&;
  15. How do parseInt and parseFloat differ? When would you use *.toFixed? — In what instance might the following code snippet actually make sense to use?

    var my_number = my_string - 0;
Something went wrong with that request. Please try again.