Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7517
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!e25g2000pri.googlegroups.com!not-for-mail |
|---|---|
| From | RobG <rgqld@iinet.net.au> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: IE and named function expressions |
| Date | Mon, 17 Oct 2011 18:44:16 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 27 |
| Message-ID | <0b6043e7-6013-43fa-ac1b-d60d8a77c42b@e25g2000pri.googlegroups.com> (permalink) |
| References | <30321d48-0e16-4790-92fa-7fe34098a747@v8g2000pro.googlegroups.com> |
| NNTP-Posting-Host | 203.8.131.32 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | posting.google.com 1318902256 6773 127.0.0.1 (18 Oct 2011 01:44:16 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Tue, 18 Oct 2011 01:44:16 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | e25g2000pri.googlegroups.com; posting-host=203.8.131.32; posting-account=6cUlVQoAAABDk3JtwhqUs005Xjt2C0dN |
| User-Agent | G2/1.0 |
| X-HTTP-Via | 1.1 localhost.localdomain[AC120214] |
| X-Google-Web-Client | true |
| X-Google-Header-Order | UALESRCVH |
| X-HTTP-UserAgent | Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0,gzip(gfe) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.javascript:7517 |
Show key headers only | View raw
On Oct 18, 11:30 am, RobG <rg...@iinet.net.au> wrote:
> I'm sure this has been discussed before but I can't find it. The
> following code:
>
> var foo;
> (function() {
> foo = function foo(){};
> }());
>
> alert(typeof foo);
>
> shows "function" in most browsers but "undefined" in IE. It appears
> that IE is creating a local variable foo inside the anonymous function
> as a consequence of the named function expression. So the function is
> assigned to a local variable and goes out of scope for the alert. But
> in non-IE browsers, foo resolves to the global foo and is in scope for
> the alert.
>
> Is this consistent with ECMA-262 or not? I'm simply not up to wading
> through the spec in sufficient detail to answer the question myself.
Managed to stumble across a reasonable article by Juriy "kangax"
Zaytsev that goes through a number of related issues: <URL:
http://kangax.github.com/nfe/#jscript-bugs >
--
Rob
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar
IE and named function expressions RobG <rgqld@iinet.net.au> - 2011-10-17 18:30 -0700
Re: IE and named function expressions RobG <rgqld@iinet.net.au> - 2011-10-17 18:44 -0700
Re: IE and named function expressions dhtml <dhtmlkitchen@gmail.com> - 2011-10-17 21:23 -0700
Re: IE and named function expressions Matt McDonald <matt@fortybelow.ca> - 2011-10-17 22:50 -0600
Re: IE and named function expressions dhtml <dhtmlkitchen@gmail.com> - 2011-10-17 23:33 -0700
Re: IE and named function expressions Dr J R Stockton <reply1142@merlyn.demon.co.uk> - 2011-10-19 19:56 +0100
Re: IE and named function expressions Antony Scriven <adscriven@gmail.com> - 2011-10-19 16:13 -0700
Re: IE and named function expressions dhtml <dhtmlkitchen@gmail.com> - 2011-10-17 21:21 -0700
csiph-web