Prev: How to link CSS(s) already linked to parent frame into child iframe using javascript
Next: Error getElementbyClassName
From: kangax on 17 Jan 2010 11:51 On 1/17/10 9:46 AM, Asen Bozhilov wrote: > kangax wrote: [...] >> Also, why only 3 out of 7? > > Which others four? I don't find good article about {DontEnum} bug in > JScript implementation. I know only for that three user defined > properties in native objects. Can you give link or example? > Thanks. Garrett explained it here <http://dhtmlkitchen.com/learn/js/enumeration/dontenum.jsp#JScriptDontEnumBug> To quote: "JScript will skip over any property in any object where there is a same-named property in the object's prototype chain that has the DontEnum attribute." For a list of `Object.prototype` properties see 15.2.4 (ES3F). -- kangax
From: kangax on 17 Jan 2010 12:03 On 1/17/10 10:02 AM, Thomas 'PointedEars' Lahn wrote: > kangax wrote: > >> Asen Bozhilov wrote: [...] >>> }, >>> >>> addProperties : function(o) >>> { >>> for (var i in o) >>> { >>> if (o.hasOwnProperty(i)) >> >> Would be safer to do: >> >> if (Object.prototype.hasOwnProperty.call(o, i)) > > How so? All built-in objects need to implement hasOwnProperty() as they > have Object.prototype in their prototype chain, and nobody sane would pass > a host object here. Think about what happens when `{ hasOwnProperty: null }` is passed to `addProperties` method. [...] -- kangax
From: Thomas 'PointedEars' Lahn on 17 Jan 2010 12:55 kangax wrote: > Thomas 'PointedEars' Lahn wrote: >> kangax wrote: >>> Asen Bozhilov wrote: > [...] >>>> }, >>>> >>>> addProperties : function(o) >>>> { >>>> for (var i in o) >>>> { >>>> if (o.hasOwnProperty(i)) >>> >>> Would be safer to do: >>> >>> if (Object.prototype.hasOwnProperty.call(o, i)) >> >> How so? All built-in objects need to implement hasOwnProperty() as they >> have Object.prototype in their prototype chain, and nobody sane would >> pass a host object here. > > Think about what happens when `{ hasOwnProperty: null }` is passed to > `addProperties` method. Nobody sane would create such an object either, or pass a reference to it to this method. PointedEars -- realism: HTML 4.01 Strict evangelism: XHTML 1.0 Strict madness: XHTML 1.1 as application/xhtml+xml -- Bjoern Hoehrmann
From: Jorge on 17 Jan 2010 13:05 On Jan 17, 6:55 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de> wrote: > kangax wrote: > > > Think about what happens when `{ hasOwnProperty: null }` is passed to > > `addProperties` method. > > Nobody sane would create such an object either, or pass a reference to it > to this method. LOL. Object.prototype.hasOwnProperty.call({ hasOwnProperty: null }, "hasOwnProperty"); --> true -- Jorge.
From: Thomas 'PointedEars' Lahn on 17 Jan 2010 13:10
Jorge wrote: > Thomas 'PointedEars' Lahn wrote: >> kangax wrote: >> > Think about what happens when `{ hasOwnProperty: null }` is passed to >> > `addProperties` method. >> >> Nobody sane would create such an object either, or pass a reference to it ^^^^^^^^^^^ >> to this method. > > LOL. > > Object.prototype.hasOwnProperty.call({ hasOwnProperty: null }, > "hasOwnProperty"); > --> true q.e.d. PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.) |