0
0
Javascriptprogramming~5 mins

Why prototypes are needed in Javascript - Quick Recap

Choose your learning style9 modes available
Recall & Review
beginner
What is a prototype in JavaScript?
A prototype is an object that other objects inherit properties and methods from. It allows sharing features between objects without copying them.
Click to reveal answer
beginner
Why do JavaScript objects use prototypes?
Prototypes let objects share methods and properties efficiently, saving memory and enabling easy updates to shared behavior.
Click to reveal answer
intermediate
How do prototypes help with method sharing?
Instead of each object having its own copy of a method, the method lives on the prototype. Objects access it through the prototype chain.
Click to reveal answer
intermediate
What happens if a property is not found on an object?
JavaScript looks up the prototype chain to find the property. If it exists on the prototype, it is used.
Click to reveal answer
beginner
How do prototypes support code reuse?
By putting shared code on prototypes, many objects can reuse the same code without duplication, making programs smaller and faster.
Click to reveal answer
What is the main purpose of prototypes in JavaScript?
ATo create new variables
BTo share properties and methods between objects
CTo store data permanently
DTo run code faster
If a property is missing on an object, where does JavaScript look next?
AIn the prototype of the object
BIn the global variables
CIn the browser cache
DIt throws an error immediately
How do prototypes help save memory?
ABy deleting unused variables
BBy compressing code automatically
CBy storing shared methods once on the prototype instead of in every object
DBy running code in the background
Which of these is true about the prototype chain?
AIt is used to find properties not directly on the object
BIt stores all variables in the program
CIt runs code faster by skipping steps
DIt is a list of all functions in the program
What happens if a property is found on both the object and its prototype?
AAn error occurs
BThe prototype's property is used
CBoth are used together
DThe object's own property is used
Explain why prototypes are important in JavaScript and how they help objects share behavior.
Think about how many objects can use the same method without copying it.
You got /4 concepts.
    Describe what happens when you try to access a property that an object does not have directly.
    JavaScript looks beyond the object itself.
    You got /3 concepts.