Prototype ? why?

i didn’t understand the reason of declaring a property using prototype instead of the normal way

Prototype is a default way to share common properties across multiple object instances in JavaScript. It is JavaScript way of enabling inheritance. This is a reason why every array can have access to array methods like .indexOf(), '.forEach()`, etc…

What you call normal way assigns a property only in the object that you assigned to. (You can’t even call it normal because assigning property to prototype is just normal, as well.)

so there is no difference between using this

Bird.prototype.numLegs = 2;

and this

Bird.numLegs = 2;


oh never mind i did a test for both of them actually the first one could add the property as a prototype to all the object while the second one did nothing :slight_smile: