10 Interview Questions
Every JavaScript Developer Should Know

AKA: The Keys to JavaScript Mastery

Eric Elliott
Oct 2, 2015 · 13 min read

Update: 2020

In the years since I wrote this article, a lot has changed. When I wrote it, lots of developers were coming to JavaScript from languages like Java and C++, lacking any understanding of how objects work in JavaScript, and trying to apply obsolete patterns, such as deeply layered inheritance hierarchies.

Original Article Starts Here

At most companies, management must trust the developers to give technical interviews in order to assess candidate skills. If you do well as a candidate, you’ll eventually need to interview. Here’s how.

It Starts With People

In “How to Build a High Velocity Development Team”, I made a couple points worth repeating:

“People, Process, Product”

The best way to evaluate a candidate
is a pair programming exercise.

1. Can you name two programming paradigms important for JavaScript app developers?

JavaScript is a multi-paradigm language, supporting imperative/procedural programming along with OOP (Object-Oriented Programming) and functional programming. JavaScript supports OOP with prototypal inheritance.

  • Functional programming (also: closures, first class functions, lambdas).

2. What is functional programming?

Functional programming produces programs by composing mathematical functions and avoids shared state & mutable data. Lisp (specified in 1958) was among the first languages to support functional programming, and was heavily inspired by lambda calculus. Lisp and many Lisp family languages are still in common use today.

  • Avoid side-effects.
  • Simple function composition.
  • Examples of functional languages: Lisp, ML, Haskell, Erlang, Clojure, Elm, F Sharp, OCaml, etc…
  • Mention of features that support FP: first-class functions, higher order functions, functions as arguments/values.
  • Unable to provide examples of functional programming languages.
  • Unable to identify the features of JavaScript that enable FP.

3. What is the difference between classical inheritance and prototypal inheritance?

Class Inheritance: instances inherit from classes (like a blueprint — a description of the class), and create sub-class relationships: hierarchical class taxonomies. Instances are typically instantiated via constructor functions with the `new` keyword. Class inheritance may or may not use the `class` keyword from ES6.

In JavaScript, prototypal inheritance is simpler &
more flexible than class inheritance.

  • Prototypes: mentions of concatenative inheritance, prototype delegation, functional inheritance, object composition.

4. What are the pros and cons of functional programming vs object-oriented programming?

OOP Pros: It’s easy to understand the basic concept of objects and easy to interpret the meaning of method calls. OOP tends to use an imperative style rather than a declarative style, which reads like a straight-forward set of instructions for the computer to follow.

  • Awareness of FP’s capability to radically simplify many applications.
  • Awareness of the differences in learning curves.
  • Articulation of side-effects and how they impact program maintainability.
  • Awareness that a highly functional codebase can have a steep learning curve.
  • Awareness that a highly OOP codebase can be extremely resistant to change and very brittle compared to an equivalent FP codebase.
  • Awareness that immutability gives rise to an extremely accessible and malleable program state history, allowing for the easy addition of features like infinite undo/redo, rewind/replay, time-travel debugging, and so on. Immutability can be achieved in either paradigm, but a proliferation of shared stateful objects complicates the implementation in OOP.

5. When is classical inheritance an appropriate choice?

The answer is never, or almost never. Certainly never more than one level. Multi-level class hierarchies are an anti-pattern. I’ve been issuing this challenge for years, and the only answers I’ve ever heard fall into one of several common misconceptions. More frequently, the challenge is met with silence.

  • A single level is sometimes OK, from a framework base-class such as React.Component.
  • “Favor object composition over class inheritance.”

6. When is prototypal inheritance an appropriate choice?

There is more than one type of prototypal inheritance:

  • Concatenative (i.e. mixins, `Object.assign()`).
  • Functional (Not to be confused with functional programming. A function used to create a closure for private state/encapsulation).
  • When you need to compose objects from multiple sources.
  • Any time you need inheritance.
  • No awareness of mixins or `Object.assign()`.

7. What does “favor object composition over class inheritance” mean?

This is a quote from “Design Patterns: Elements of Reusable Object-Oriented Software”. It means that code reuse should be achieved by assembling smaller units of functionality into new objects instead of inheriting from classes and creating object taxonomies.

  • Avoid brittle base class problem.
  • Avoid tight coupling.
  • Avoid rigid taxonomy (forced is-a relationships that are eventually wrong for new use cases).
  • Avoid the gorilla banana problem (“what you wanted was a banana, what you got was a gorilla holding the banana, and the entire jungle”).
  • Make code more flexible.
  • Fail to articulate the difference between composition and class inheritance, or the advantages of composition.

8. What are two-way data binding and one-way data flow, and how are they different?

Two way data binding means that UI fields are bound to model data dynamically such that when a UI field changes, the model data changes with it and vice-versa.

  • Angular is a popular framework which uses two-way binding.

9. What are the pros and cons of monolithic vs microservice architectures?

A monolithic architecture means that your app is written as one cohesive unit of code whose components are designed to work together, sharing the same memory space and resources.

  • Practical about microservices vs monolithic apps. Structure the app so that services are independent from each other at the code level, but easy to bundle together as a monolithic app in the beginning. Microservice overhead costs can be delayed until it becomes more practical to pay the price.
  • Unaware or impractical about the additional overhead of microservices.
  • Unaware of the additional performance overhead caused by IPC and network communication for microservices.
  • Too negative about the drawbacks of microservices. Unable to articulate ways in which to decouple monolithic apps such that they’re easy to split into microservices when the time comes.
  • Underestimates the advantage of independently scalable microservices.

10. What is asynchronous programming, and why is it important in JavaScript?

Synchronous programming means that, barring conditionals and function calls, code is executed sequentially from top-to-bottom, blocking on long-running tasks such as network requests and disk I/O.

  • An understanding of event handling, and why its important for UI code.
  • Unable to articulate performance implications or the relationship between asynchronous code and UI code.


Stick to high-level topics. If they can answer these questions, that typically means that they have enough programming experience to pick up language quirks & syntax in a few weeks, even if they don’t have a lot of JavaScript experience.

Image for post
Image for post
Start your free lesson on EricElliottJS.com

JavaScript Scene

JavaScript, software leadership, software development, and…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store