This is because when calling getFull the Javascript runtime will check for the method on the instance of the Person it won't be found there directly so it will then check the prototype of Person to find it. However, there will be a slight decrease in the speed of invoking a method in comparison to the first approach. One should note though that modern Javascript engines such as V8 are smart enough for not to recreate instances of a method thanks to hidden classes.Īpart from low memory usage, the prototype approach is obviously faster in execution when creating new object instances since no time is spent on re-declaring any methods. Now having our object instances based on the second example, we will be able to save a significant amount of memory compared to the first approach as the number of instances of the constructor grows larger within the application.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |