Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
JavaScript 10 questions

Object-Oriented JavaScript

Learn class structures, constructor methods, encapsulation, encapsulation fields, static methods, and prototype-based programming.

More JavaScript
Interview questions 1–10 of 10
1

What are the four main principles of OOP and how does JavaScript support them?

PrincipleMeaningHow JavaScript supports itEncapsulationBundling data and methods, hiding internal detailsPriva...

Read answer →
2

How do private class fields (#field) work in JavaScript?

Private fields, prefixed with #, are truly inaccessible from outside the class - unlike the old convention of...

Read answer →
3

How do getters and setters work in JavaScript classes?

Getters and setters let you define methods that are accessed like properties, enabling computed properties and...

Read answer →
4

What is method overriding and how does super work with it?

Method overriding lets a subclass provide its own implementation of a method inherited from a parent class. Th...

Read answer →
5

What is composition and how does it compare to inheritance in JavaScript?

Composition builds objects by combining smaller, focused pieces of functionality rather than through a class h...

Read answer →
6

How does the instanceof operator work and what are its limitations?

instanceof checks whether a constructor's prototype exists anywhere in an object's prototype chain. It works w...

Read answer →
7

How do abstract-like classes and interfaces work in JavaScript, since it doesn't natively support them?

JavaScript has no built-in 'abstract class' or 'interface' keywords, but the same design intentions can be enf...

Read answer →
8

What is the difference between class fields and constructor-assigned properties?

Class fields (introduced in ES2022) let you declare instance properties directly in the class body, offering a...

Read answer →
9

How do you implement the Singleton pattern in JavaScript?

The Singleton pattern ensures a class has only one instance and provides a global point of access to it - usef...

Read answer →
10

How do you implement encapsulation in JavaScript before private fields existed (using closures)?

Before the # syntax was standardized, closures were the primary way to achieve true data privacy - variables i...

Read answer →