Prev: Google.com is broken in Firefox 3.6.3
Next: FAQ Topic - How do I get my browser to report javascript errors?(2010-05-08)
From: Dr J R Stockton on 7 May 2010 17:04 The expression typeof eval("(function F(){return 3})") gives "function" in Firefox and Chrome (and probably in Opera and Safari); but in IE8 it gives "undefined". What do I need to do to get the same in IE8 as in the others, i.e. for eval to return an actual executable function, which would return 3 ? -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
From: Garrett Smith on 7 May 2010 18:13 Dr J R Stockton wrote: > The expression typeof eval("(function F(){return 3})") gives > "function" in Firefox and Chrome (and probably in Opera and Safari); but > in IE8 it gives "undefined". > Yes it does, unfortunately. > What do I need to do to get the same in IE8 as in the others, i.e. for > eval to return an actual executable function, which would return 3 ? > var f = eval("(function(){ return 3; })||0;"); var f2 = new Function("return 3;"); In ES3, the eval function uses containing scope. The Function constructor results in a function that has global scope. -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Ry Nohryb on 8 May 2010 04:01 On May 7, 11:04 pm, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk> wrote: > The expression typeof eval("(function F(){return 3})") gives > "function" in Firefox and Chrome (and probably in Opera and Safari); but > in IE8 it gives "undefined". Have you tried with: txt= "function F(){return 3}"; eval("(function () { return "+ txt+ "})()"); ¿? -- Jorge
From: Ry Nohryb on 8 May 2010 04:11 On May 8, 10:01 am, Ry Nohryb <jo...(a)jorgechamorro.com> wrote: > On May 7, 11:04 pm, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk> > wrote: > > > The expression typeof eval("(function F(){return 3})") gives > > "function" in Firefox and Chrome (and probably in Opera and Safari); but > > in IE8 it gives "undefined". > > Have you tried with: > > txt= "function F(){return 3}"; > eval("(function () { return "+ txt+ "})()"); > > ¿? Or with: eval("(function () { function F () { return 3; }; return F; })()"); ¿? -- Jorge.
From: williamc on 8 May 2010 08:21
On 5/7/2010 5:04 PM, Dr J R Stockton wrote: > The expression typeof eval("(function F(){return 3})") gives > "function" in Firefox and Chrome (and probably in Opera and Safari); but > in IE8 it gives "undefined". > > What do I need to do to get the same in IE8 as in the others, i.e. for > eval to return an actual executable function, which would return 3 ? > Question: why does 'function F(){return 3}' need the parentheses around it to eval to 'function' in the non-IE implementations? |