You need to be careful of named function expressions, for IE. There's
a dangerous memory leak pattern that all versions of IE suffer from.

This code:

return function ext(o){
    // ...
};

It was explained that the use of "ext" here (which is in fact the
named function expression pattern) was to avoid the use of
arguments.callee. Unfortunately, this named function expression usage
creates a memory leak in IE.

Normally, if you were to do an expression like that, you could fix
this memory leak by assigning a null value to the named identifier.
For instance:

var foo = function ext(o) {
   // ...
};
return foo;

That code would do the same thing, and create the same memory leak.
However, it would allow you to fix it like this:

var foo = function ext(o) {
  // ...
};
ext = null; // squashes the IE memory leak with named function
expressions
return foo;

Here's the article which discusses the memory leak pattern in IE and
how to fix it:

http://yura.thinkweb2.com/named-function-expressions/

Scroll about half way down to see the discussion of JScript's (IE)
bugs with named function expressions.

Bottom line (IMHO)... even though it's technically going to be
deprecated at some point, use arguments.callee instead of named
function expressions, unless you are prepared to make sure you "fix"
this bug every time you do.





On Oct 23, 8:20 pm, gMinuses <gminu...@gmail.com> wrote:
> This is a very smart strategy, never aware of that. I think I can
> benefit a lot from it. Thanks for mentioning!
>
> On Oct 24, 2:23 am, Andrea Giammarchi <andrea.giammar...@gmail.com>
> wrote:
>
>
>
> > Hi Scott, almost everything fine ...
>
> > On Fri, Oct 23, 2009 at 6:39 PM, Scott Sauyet <scott.sau...@gmail.com>wrote:
>
> > > So the only thing left is the actual definition of "ext".  Nothing to
> > > it, right?  :-)
>
> > extend
>
> > Note that the re-use of the name ext in this declaration is not
>
> > > necessary.
>
> > named functions are good for debugging purpose while repeated words are
> > almost meaningless, size speaking, for gzipped code
>
> > About the other question, it's almost the same except I use a bedgeObject
> > strategy avoiding a for in loop relying the Object.clone emulator (so 1 for
> > in for the object rather than 2 as you did, not a big deal in any case)
>
> > Regards- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to