List Info

Thread: Re: some question about 'eval'




Re: some question about 'eval'
country flaguser name
Spain
2008-04-22 12:02:22

To start with, eval is evil. Avoid it as much as possible. You don't need
to use eval to do what you want here. Actually it is harder to do what you
want using eval than not.

When something goes wrong, change the eval for an alert and see what is it
that the alert shows. That's what eval will try to execute. In this case,
it will show:

a(Object)

Where Object is probably not defined so function a() will get undefined as
the value of its argument and undefined has no members.

Satyam

----- Original Message -----
From: "lujin.0520"; < lujin.0520%40yahoo.com.cn">lujin.0520yahoo.com.cn>
To: < ydn-javascript%40yahoogroups.com">ydn-javascriptyahoogroups.com>;
Sent: Tuesday, April 22, 2008 1:19 AM
Subject: [ydn-javascript] some question about 'eval'

> function a(o) {
> alert(o.a);
> }
> eval('a(' + {a:'abc'} + ')');
&gt;
>
>
>; ===========
> it does not work.
&gt; How can I do this?
&gt;
>
> ------------------------------------
&gt;
> Yahoo! Groups Links
&gt;
>
>
>;

__._,_.___
.

__,_._,___
Re: some question about 'eval'
country flaguser name
United States
2008-06-11 09:28:46

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )