[Proto-Scripty] Re: IE eval() question...

2008-12-05 Thread RobG



On Dec 4, 11:17 am, yoshi [EMAIL PROTECTED] wrote:
 heres my js:

 var stuff7=eval('function() {alert(stuff..);}')

 when i alert stuff7 it is undefined.

The code passed to eval is treated at a function declaration.  Without
a name, it is a syntax error.



 now if i do this:
 eval('var stuff7=function() {alert(stuff..);}')

 and alert stuff7, it is defined

Because now it is a valid function expression.  You could also use a
valid function declaration:

eval('function stuff7() {alert(stuff..);}')


 does anybody know y, the jscript eval doc doesnt really help,

No surprises there, it is a user guide, not a specification.  Use
ECMA-262, section 10.2.2.


 i suspect it is a scope issue?

It's a syntax error.


--
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: IE eval() question...

2008-12-04 Thread yoshi

i think u guys are assuming firefox, in IE eval without the function
wrapped in () does not cause syntax err, and even if i added the '()',
like

var stuff7=eval('(function() {alert(stuff..);})')

stuff7 is still undefinedaccording to IE8 beta2's js console
that is.











On Dec 3, 9:36 pm, yuval dagan [EMAIL PROTECTED] wrote:
 try it like this:
 add  ( and )
 var stuff7=eval('(function() {alert(stuff..);})')

 thats because the interpreter rules of running the script

 On Thu, Dec 4, 2008 at 3:17 AM, yoshi [EMAIL PROTECTED] wrote:

  heres my js:

  var stuff7=eval('function() {alert(stuff..);}')

  when i alert stuff7 it is undefined.

  now if i do this:
  eval('var stuff7=function() {alert(stuff..);}')

  and alert stuff7, it is defined

  does anybody know y, the jscript eval doc doesnt really help, i
  suspect it is a scope issue?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: IE eval() question...

2008-12-04 Thread Matt Foster

Try ending the statement with a semicolon, it is probably hitting the
syntax error there.

var stuff = eval('(function(){ ... });');




On Dec 4, 1:59 pm, yoshi [EMAIL PROTECTED] wrote:
 i think u guys are assuming firefox, in IE eval without the function
 wrapped in () does not cause syntax err, and even if i added the '()',
 like

 var stuff7=eval('(function() {alert(stuff..);})')

 stuff7 is still undefinedaccording to IE8 beta2's js console
 that is.

 On Dec 3, 9:36 pm, yuval dagan [EMAIL PROTECTED] wrote:

  try it like this:
  add  ( and )
  var stuff7=eval('(function() {alert(stuff..);})')

  thats because the interpreter rules of running the script

  On Thu, Dec 4, 2008 at 3:17 AM, yoshi [EMAIL PROTECTED] wrote:

   heres my js:

   var stuff7=eval('function() {alert(stuff..);}')

   when i alert stuff7 it is undefined.

   now if i do this:
   eval('var stuff7=function() {alert(stuff..);}')

   and alert stuff7, it is defined

   does anybody know y, the jscript eval doc doesnt really help, i
   suspect it is a scope issue?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---