Carl-Erik Kopseng

30%
Flag icon
This approach has a serious drawback in that it creates three function objects for every person object created. The original approach using a closure when adding properties to the prototype will only ever create three function objects that are shared between all circle objects. This means that creating n circle objects will cause the latter version to use approximately n times as much memory as the original suggestion. Additionally, object creation will be significantly slower because the constructor has to create the function objects as well. On the other hand, property resolution is quicker ...more
Carl-Erik Kopseng
notes on Crockfords module pattern
Test-Driven JavaScript Development (Developer's Library)
Rate this book
Clear rating