The first one, John Stocktons site has a textarea for input of
script to test it. When testing it, it seems to be the best way to
do it (using eval).
The other one was a problem I had a while back (it was discussed
here) where I had a select list that had fractions as its value.
I remember that
The fractions were random in the sense that they weren't always the
same denominator. The problem was trying to convert the fraction to
a decimal. It turned out that, in some browsers, eval performed at
the same level as splitting on the / and then dividing.
If it was only at the same level, then I wouldn't use eval. You need
total control of the arguments to eval (or a syntax check), which should
outweigh the advantage you get from shorter code.
As for speed. As far as I can see, eval is *much* slower (more tha 5x)
than using split in IE 6. A little faster yet is finding the "/" with
indexOf and using substring to get the parts:
var i = str.indexOf("/");
return str.substr(0,i)/str.substr(i+1);
In Opera 7.2, split was fastest and eval slowest. In MozFB, split and
eval are comparable. In Netscape 4.8, eval is actually twice as fast
as split, and 1.5 times as fast as using substring. It is generally
slower than the other browsers, though.
Where's the one place you use it?
A text area for input of scripts (actually the one that I link to in
this signature).
/L