On Fri, Dec 9, 2011 at 8:57 PM, Bruno Jouhier <[email protected]> wrote: > The following prints "item=function" on IE9!! > > <html><body><script> > function foo() { > item = "hello"; > alert("item=" + typeof item); > } > foo(); > </script></body></html> > > Of course, it is lacking a "var" before "item", but the result is > surprising.
Not really. I'm guessing you're using IE. In IE the window object has an "item" property holding a function. It's not writable, so assigning to the property does nothing. Reading its type gives the expected "function" Other browsers (checked Firefox and Chrome) doesn't have the global "item" property, and alerts "item=string". > Also, I tried with "use strict"; at the beginning of foo but it did > not help! What did you expect adding "use strict" would do? /L -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
