I was expecting that assignment to a non writable property would throw. The fact that it does nothing *silently* is problematic IMO.
On 9 déc, 21:10, Lasse Reichstein <reichsteinatw...@gmail.com> wrote: > On Fri, Dec 9, 2011 at 8:57 PM, Bruno Jouhier <bjouh...@gmail.com> 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/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com