Can anyone explain to me more? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anyone explain to me more?

All objects in JavaScript have a prototype. A prototype is another object that the original object inherits from. The original object has access to all of its prototype's methods and properties. #CodeNewbie

18th May 2021, 9:06 AM
HUNTER BOYZ
HUNTER BOYZ - avatar
1 Answer
+ 1
an object could have properties (values) and methods (functions) attached to it: as a car object could have a manufacturer name, and a drive method... specific to all cars. a car could also have an owner name, wich is specific to each car. so the prototype could define the manufacturer name and the drive method for all cars, while each object instances could define their owners... this avoid defining shared values between all objects of one class multiple times (and spare some memory), while allow to only define each instance specific properties (and eventually methods) ;P
18th May 2021, 9:23 AM
visph
visph - avatar