|Monday, 04 October 2010|
Page 3 of 3
So after the assignment Points[i] has its very own z property and no longer makes use of the prototype mechanism to fill in for a property it doesn't have.
You can see that providing a prototype property is a storage saver initially at least. It provides default values for all of the properties that an object gets via the prototype mechanism without allocating any additional storage. As the objects make use of the properties to store unique values then the additional storage is allocated - its a neat mechanism once you understand it.
Of course the prototype mechanism works in exactly the same way for properties and methods - the only difference is that you usually don't assign a new "value" to an inherited method. As we shall see in the next article however redefining a method that has been supplied as a prototype is one of the core things that you do if you start to use its as a way of implementing inheritance.
|Last Updated ( Monday, 18 October 2010 )|