News for hackers. Stuff that matters.
Re:Javascript: is 'this' a code smell? by bni on Friday November 05, 2010 @08:31AM (#1872875)
Thanks for the benchmarks, I know the tradeoff for using this pattern.

Im aware of that the function is defined in each object, and that it takes up memory. I dont agree that the memory is leaked, it is reclaimed when the object is deleted.

As I never create millions of instances of objects, and this patterns dont seem to have a measurable impact on the rendering loop in my project, Ill just continue using it for now.

I would call the pattern you propose to be the "object factory" pattern. And I am curious how to do classical inheritance and encapsulated vars with it.

There are no comments on this comment yet.