> The NewExpression pattern is the solution to a different problem. If your 
> application code needs more then one of these "counter" objects, then yes, 
> I'd say create a full constructor and extend its prototype - otherwise, it's 
> unnecessary code clutter.

True. I was assuming you were creating multiple objects, since you
created a function to begin with that used `this` :)

> As for performance and optimization, you said "the difference will hardly be 
> noticable" - this is simply not true. I set up a test on jsperf.com, but for 
> some reason my results where not being stored to browserscope, so I took some 
> screen shots:

Ah, good point. I hadn't thought about this. In all fairness, that
(my) comment was aimed at spawning multiple functions vs creating
functions once with the prototype. It was not about running at all.
And if at any time you are creating new instances with the amounts of
jsperf, you seriously need to reconsider your design pattern anyways,
objects is not the way to go (in that case!) :)

I guess the moral of the story is that different situations require
different approaches. Luckily js offers quite a few :p

- peter

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to