Question Bank

Prototype Chain and Inheritance Quiz

Difficulty: Medium

Practice the prototype-chain mechanics: extending built-ins, defining shared properties on `Object.prototype`, and traversing the chain via `Object.getPrototypeOf`.

Question Bank
/

Prototype Chain and Inheritance Quiz

Prototype Chain and Inheritance Quiz

Practice the prototype-chain mechanics: extending built-ins, defining shared properties on `Object.prototype`, and traversing the chain via `Object.getPrototypeOf`.

Question Bank
Medium
JavaScript
4 questions
quiz
js-prototypes
inheritance
classes

540 views

8

Augment Array.prototype with a sum() method that returns the sum of the array's numeric elements, then explain one reason this is generally considered an anti-pattern.

Examples

Example 1:

Input: [1, 2, 3, 4].sum()
Output: 10
Explanation: Adding to `Array.prototype` makes the method available on every array literal because of the prototype chain.