JavaScript Scene
Published in

JavaScript Scene

10 Interview Questions
Every JavaScript Developer Should Know

AKA: The Keys to JavaScript Mastery

Update: 2020

Original Article Starts Here

It Starts With People

“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?

  • Prototypal inheritance (also: prototypes, OLOO).
  • Functional programming (also: closures, first class functions, lambdas).
  • No clue what a paradigm is, no mention of prototypal oo or functional programming.

2. What is functional programming?

  • Pure functions / function purity.
  • 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.
  • No mention of pure functions / avoiding side-effects.
  • 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?

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

  • Classes: create tight coupling or hierarchies/taxonomies.
  • Prototypes: mentions of concatenative inheritance, prototype delegation, functional inheritance, object composition.
  • No preference for prototypal inheritance & composition over class inheritance.

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

  • Mentions of trouble with shared state, different things competing for the same resources, etc…
  • 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.
  • Unable to list disadvantages of one style or another — Anybody experienced with either style should have bumped up against some of the limitations.

5. When is classical inheritance an appropriate choice?

  • Rarely, almost never, or never.
  • 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?

  • Delegation (i.e., the prototype chain).
  • 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).
  • In situations where modules or functional programming don’t provide an obvious solution.
  • When you need to compose objects from multiple sources.
  • Any time you need inheritance.
  • No knowledge of when to use prototypes.
  • No awareness of mixins or `Object.assign()`.

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

  • Avoid class hierarchies.
  • 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 mention any of the problems above.
  • 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?

  • React is the new canonical example of one-way data flow, so mentions of React are a good signal. Cycle.js is another popular implementation of uni-directional data flow.
  • Angular is a popular framework which uses two-way binding.
  • No understanding of what either one means. Unable to articulate the difference.

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

  • Positive attitudes toward microservices, despite the higher initial cost vs monolthic apps. Aware that microservices tend to perform and scale better in the long run.
  • 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 of the differences between monolithic and microservice architectures.
  • 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?

  • An understanding of what blocking means, and the performance implications.
  • An understanding of event handling, and why its important for UI code.
  • Unfamiliar with the terms asynchronous or synchronous.
  • Unable to articulate performance implications or the relationship between asynchronous code and UI code.

Conclusion

Start your free lesson on EricElliottJS.com

--

--

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