mozilla

Revision 134210 of eval

  • Revision slug: Talk:JavaScript/Reference/Global_Objects/eval
  • Revision title: eval
  • Revision id: 134210
  • Created:
  • Creator: Fdrake1
  • Is current revision? No
  • Comment

Revision Content

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{{ mediawiki.external("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{{ mediawiki.external("0") }}{{ mediawiki.external('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)

Revision Source

<p>There are some bad examples here.
</p><p>First, all statements should have semicolons. Although optional, it should definitely be encouraged.
</p><p>Second, the last example has this: <code>eval ("document.forms{{ mediawiki.external("0") }}." + textObject + ".value") = newValue</code>. That is a <i>really</i> bad use of eval. eval shouldn't be used at all there! It should be <code>document.forms{{ mediawiki.external("0") }}{{ mediawiki.external('textObject') }}.value</code>
</p><p>--<a href="User:Maian">Maian</a> 23:19, 24 Aug 2005 (PDT)
</p>
<dl><dd> 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. --<a href="User:Nickolay">Nickolay</a> 02:13, 25 Aug 2005 (PDT)
</dd></dl>
<p>I found only one missing semi-colon, which I added. Any others needed were added before I stumbled across this page.
</p><p>I'd like to see more discussion of the second argument to <code>eval</code> 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.
</p><p>--<a href="User:Fdrake1">Fdrake</a> 02:18, 04 Jan 2008 (EDT)
</p>
Revert to this revision