|
Posted by Jonathan N. Little on 11/07/05 03:56
X l e c t r i c wrote:
> Actually my point was about the unnecessary use of eval.
>
> Michael and the other experts at comp.lang.javascript have helped me
> many times, cwdjr too. And even though in this case his reply was more
> directly related to and appropriate for the OP's question, who is to say
> what is "far better". As we don't know the context with which this bit
> of code will be used.
>
> I could easily say that this:
>
> var hither = "Close by";
> var yonder = "In the hills!";
> alert(hither);
> alert(yonder);
>
> is far more efficient and practical than what you offer, as the results
> will be the same with a more simplistic approach. What I can't say
> though is that this is the solution in any given situation without
> knowing the application.
I agree accessing variables directly is simpler and more efficient, but
the OP was looking for a JS version of a PHP's variable variable which
the above method does not address. Personally I avoid variable
variables, I find you can really get yourself into trouble and they can
be a b*tch to debug, but again it was what the OP asked.
--
Take care,
Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Navigation:
[Reply to this message]
|