i came across this post http://www.webmasterworld.com/javascript/3066162.htm
about how in javascript when you instantiate an object literal if it has methods defined in it then each time one is instantiated its methods are copied as well. so if you have a bunch of instances of the object literal then the copied methods would begin to add up in memory.
how ever he/she states that using prototype to make your methods is more efficient because the methods are not copied for each instance of the constructor object.
is this true? because i was under the impression that prototype allowed you to add properties/methods even after the object was instantiated rather than within the object when its first created.
It is true, that is why there is a
prototype.Using
Foo.prototypeprevents the unnecessary extra bits associated with redefininghellobarfor every instancenew Foo().