On Nov 15, 9:58 am, Tobie Langel <[EMAIL PROTECTED]> wrote:
> sorry, Kangax for the delay in getting back to you. My computer turned
> off before I could click send last night.
>
> Of course, we can return named function.
>
> What I'd want to avoid, however, (for measurable[1] performance hit
> _every time the function is called_) is multiple closures.
>
> So we should be avoiding the following construct:
>
> (function() {
> var index = 1;
> return (function() {
> if (SOME_FEATURE_TEST) {
> return function namedFunc() { return index }
> }
> return function namedFunc2() { return index + 1 }
> })();
>
> })()
Interesting.
It's also surprising that one more scope in a scope chain could
actually affect performance noticeably. I'll definitely take a closer
look at this (and maybe do some tests) when I get a chance.
>
> [1]http://blog.zenbe.com/2008/11/07/jslitmus-a-tool-for-testing-javascri...
--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---