JScript bug in IE 6, 7, 8

Discussion in 'Internet Explorer' started by Federico Lebrón, Jul 30, 2009.

  1. I didn't know where else to report this - is this the correct place? If not,
    where should I do so?
    Basically there's a bug on how IE's JScript expands global variable names.

    If one does
    for(foo in {'a':'b', 'c':'d'}) { alert(foo); }
    One gets the expected alerts for 'a' and 'c'.

    However, if one chooses to use the variable name 'item', as such:
    for(item in {'a':'b', 'c':'d'}) { alert(item); }

    One gets an error, saying the 'object does not support this action'. Digging
    a bit deeper, this happens not only with the word 'item', but any property of
    the window object, or its prototype (any property to which it responds, like
    toString). It seems IE JScript is expanding 'item' to 'window.item', and what
    results is 'for(window.item in ...', which is wrong.

    This does not happen if scoping with the 'var' keyword, since then the
    engine knows it's a local variable, not a property of the global object.

    There's a few reports of this on the web, but I figure I'd report it and see
    if it can get fixed in IE9 or whatever the next version is? I couldn't find
    any reports directly to MS on the matter.

    Federico Lebrón, Jul 30, 2009
    1. Advertisements

  2. PA Bear [MS MVP], Jul 30, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.