What is difference between define function by prototype and class property?

When you create more than one instance of Apple, you will still only have only one instance of say() in memory. However, when you create more than one instance of Banana, you will end up creating lots of instances of the say() function.

That’s why prototypes save memory. You also avoid the processing cost of creating and assigning the say() function.

Also, if you change the parent object’s properties, if the child does not replace that property, changes are visible from the child.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)