Recall & Review
beginner
What is prototype inheritance in JavaScript?
Prototype inheritance is a way objects in JavaScript can share properties and methods through a linked prototype object. When you access a property, JavaScript looks for it on the object, and if not found, it checks the prototype chain.
Click to reveal answer
beginner
How do you set the prototype of an object in JavaScript?
You can set the prototype of an object using
Object.create(proto) to create a new object with proto as its prototype, or by using Object.setPrototypeOf(obj, proto).Click to reveal answer
intermediate
What is the role of
constructor in prototype inheritance?The
constructor property points back to the function that created the object. It helps identify the type of the object and is useful when creating new instances.Click to reveal answer
beginner
Explain the prototype chain in simple terms.
The prototype chain is like a family tree for objects. If an object doesn’t have a property, JavaScript looks up to its prototype, then that prototype’s prototype, and so on, until it finds the property or reaches the end.
Click to reveal answer
beginner
How does JavaScript find a method when you call it on an object?
JavaScript first looks for the method on the object itself. If it’s not there, it looks up the prototype chain until it finds the method or reaches the end (null).
Click to reveal answer
Which of the following is true about prototype inheritance in JavaScript?
✗ Incorrect
JavaScript uses prototype-based inheritance where objects inherit properties through a linked prototype chain.
How can you create a new object that inherits from another object
parentObj?✗ Incorrect
Object.create(parentObj) creates a new object with parentObj as its prototype.What does the
constructor property of an object refer to?✗ Incorrect
The
constructor property points to the function that created the object.If a property is not found on an object, where does JavaScript look next?
✗ Incorrect
JavaScript looks up the prototype chain to find the property.
What will
Object.getPrototypeOf(obj) return?✗ Incorrect
Object.getPrototypeOf(obj) returns the prototype linked to obj.Describe how prototype inheritance works in JavaScript and why it is useful.
Think about how objects share features without copying.
You got /4 concepts.
Explain how to create an object that inherits from another object and how to access inherited properties.
Consider how JavaScript finds properties when you use dot notation.
You got /4 concepts.