On Aug 17, 6:49 pm, Stephan Beal <[EMAIL PROTECTED]> wrote:
> According to the rhino book:
...

One more follow-up here and i'll shut up:

Also according to the rhino book:

"The Function() constructor parses the function body and creates a new
function object each time it is called. ... By contrast, a function
literal or nested function that appears within a loop or function is
not recompiled each time it is encountered."

So using Function(...) inside an $(...).each() loop could be
disastrous, memory-wise.

To summarize, the main problems with passing strings to create
Function instances, compared to using anonymous functions, are:

a) scoping rules are different (more eval()-like, no lexical scoping)
for Function, as opposed to lexical scoping for anonymous functions.

b) Function(...) body is recompiled on each call, whereas function
does not.

Only (a) should directly affect a user, but (b) would certainly come
up at some point when someone traverses a table with 5k+ cells in it.

Reply via email to