There are some bad examples here.

First, all statements should have semicolons. Although optional, it should definitely be encouraged.

Second, the last example has this: eval ("document.forms[0]." + textObject + ".value") = newValue. That is a really bad use of eval. eval shouldn't be used at all there! It should be document.forms[0][textObject].value

--Maian 23:19, 24 Aug 2005 (PDT)

This is a wiki, so go ahead and fix this. If someone thinks your changes are inappropriate (I'm not talking about the changes you suggested here), they can revert the page and explain why they did so on the talk page. --Nickolay 02:13, 25 Aug 2005 (PDT)

I found only one missing semi-colon, which I added. Any others needed were added before I stumbled across this page.

I'd like to see more discussion of the second argument to eval and how it affects the result; that's the kind of information I was looking for. The description also needs to have information about error conditions added: what happens if the expression can't be parsed, for instance, or if evaluation fails for other reasons.

--Fdrake 02:18, 04 Jan 2008 (EDT)

---- Is there a function to compile a statement to be evaluated multiple times without recompiling every time? I tried new Function() but that won't automatically return the value of the last statement in the string, and if i add a "return" keyword it won't work at all with multiple statements. Random832 28 May 2009

Document Tags and Contributors

Contributors to this page: Random832, Fdrake1, Maian, Nickolay
Last updated by: Random832,