On Aug 17, 12:32 pm, Stephan Beal <[EMAIL PROTECTED]> wrote: > a) scoping rules are different (more eval()-like, no lexical scoping) > for Function, as opposed to lexical scoping for anonymous functions.
Exactly, which is the caveat I put in my original post. This does have an advantage, though, in that potential memory leaks caused by closures are always avoided. I've used Function() many times just for this purpose, when the internal function doesn't need to retain any enclosing scope. > b) Function(...) body is recompiled on each call, whereas function > does not. Only each time it is evaluated, not each time the resulting function is called. For example, for (var i=0; i<10; i++) { var f = new Function("alert('test')"); f(); } That would re-compile the function 10 times. But this: var f = new Function("alert('test')"); for (var i=0; i<10; i++) { f(); } compiles it only once, so there is no performance hit. And this would be the case in the change I suggested. Matt Kruse