JavaScript OOP Flashcards
(13 cards)
Which term describes the ability of different classes to be treated as instances of the same class through inheritance?
Polymorphism
Which of the following is the primary mechanism for code reuse in object-oriented JavaScript?
Inheritance
Which pattern in JavaScript involves creating a single shared instance of a class to be used throughout an application?
Singleton
How do you call the constructor of a parent class from within a child class in ES6?
super()
How do you define a getter method inside a JavaScript class?
get propertyName() { … }
In ES6 and later, which keyword is used to declare a class?
class
Which of the following best describes encapsulation?
Bundling of data and methods that operate on data within a single unit.
Which of the following are pillars of object-oriented programming? Select all that apply.
Inheritance,
Encapsulation,
Abstraction
How can you create a new instance of an object in JavaScript?
new instanceName()
Which feature of OOP ensures that the internal representation of an object is hidden from the outside?
Encapsulation
In JavaScript ES6, how can a class inherit from another class?
class Child extends Parent {}
Which keyword in JavaScript is used to create an object prototype?
prototype
What is a constructor function in JavaScript?
A function that can be called to create an instance of an object.