[ANN] Updated Javascript Best Practices document

R

Randy Webb

(e-mail address removed) said the following on 6/13/2006 12:56 AM:

And from the best practices document, regarding eval:


It seems to me that it's most often used to evaluate JSON in response
to an XmlHttpRequest call. Why is this a bad idea?

That is not what eval is "most often used for" though. You see it a lot
when people are trying to do what the document refers to - accessing
without using Square Brackets.

Suppose you are using dynamic element ID's or don't know the ID (it is
passed to a function). Instead of writing this:

document.forms['formID'].elements[elementName].value;

You see people do this - a lot:

eval('document.formID.'+elementName+'.value')

Same goes with any other Dot Notation usage where the Name or ID is not
know but is passed in.

You also see it in some of Macromedia's functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top