Interview Q&A / Object-Oriented Programming

INTERVIEW Q&A · 69 QUESTIONS

Object-Oriented Programming interview questions

The four pillars, interfaces, abstract classes and design basics.

  1. How do you do dependency injection in JavaScript without any framework?

    Pass the dependency as an argument, either to a factory function or a class constructor. A function that receives what it needs is already using dependency injection.

    BeginnerQuick answer1 min read
  2. Why use a factory instead of calling new directly?

    A factory hides which concrete class is created and how. Callers ask for what they need, and creation rules can change in one place without touching the callers.

    BeginnerQuick answer1 min read