Prev: How to link CSS(s) already linked to parent frame into child iframe using javascript
Next: Error getElementbyClassName
From: John G Harris on 17 Jan 2010 14:04 On Sat, 16 Jan 2010 at 22:04:06, in comp.lang.javascript, Thomas 'PointedEars' Lahn wrote: >John G Harris wrote: > >> Thomas 'PointedEars' Lahn wrote: >>> John G Harris wrote: >>>> Javascript is more flexible. >>> There is no "Javascript", [...] >> >> Yes there is, but only at the beginning of sentences (in English). > >Nonsense. Please get yourself informed: > ><http://PointedEars.de/es-matrix> 'javascript' is the name of a class of languages : all those languages that include ECMAScript or something very close to it. In English it is quite common to use the class name when talking about a feature common to every member of the class. For instance, "The family car is designed for economy, not for speed". Family car is a class name. Therefore, your reply is wrong; javascript is more flexible (e.g than Java). John -- John Harris
From: Garrett Smith on 17 Jan 2010 14:11 John G Harris wrote: > On Sat, 16 Jan 2010 at 22:04:06, in comp.lang.javascript, Thomas > 'PointedEars' Lahn wrote: >> John G Harris wrote: >> >>> Thomas 'PointedEars' Lahn wrote: >>>> John G Harris wrote: >>>>> Javascript is more flexible. >>>> There is no "Javascript", [...] >>> Yes there is, but only at the beginning of sentences (in English). >> Nonsense. Please get yourself informed: >> >> <http://PointedEars.de/es-matrix> > > 'javascript' is the name of a class of languages : all those languages > that include ECMAScript or something very close to it. > > In English it is quite common to use the class name when talking about a > feature common to every member of the class. For instance, "The family > car is designed for economy, not for speed". Family car is a class name. > Right, and we use in our HTML "text/javascript" and name the files ".js" and in conversation. For example: Ed: "hey, did you fix the javascript error?" Joe: "Javascript error? Where?!" -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Garrett Smith on 17 Jan 2010 14:30 Thomas 'PointedEars' Lahn wrote: > 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. > > YAHOO has a hasOwnProperty method, so it is not inconceivable: http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_hasOwnProperty -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Thomas 'PointedEars' Lahn on 17 Jan 2010 17:24 Garrett Smith wrote: > Thomas 'PointedEars' Lahn wrote: >> 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. > > YAHOO has a hasOwnProperty method, so it is not inconceivable: > http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_hasOwnProperty q.e.d. Regardless, either that user-defined method does what it is supposed to do, or that is a bug in `YAHOO.lang'. Either way, it is nothing that requires the attention of the the developer of the used library (that which contains the code above). PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Garrett Smith on 17 Jan 2010 19:22
Thomas 'PointedEars' Lahn wrote: > Garrett Smith wrote: > >> Thomas 'PointedEars' Lahn wrote: >>> 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. >> YAHOO has a hasOwnProperty method, so it is not inconceivable: >> http://developer.yahoo.com/yui/docs/YAHOO.lang.html#method_hasOwnProperty > > q.e.d. > > Regardless, either that user-defined method does what it is supposed to do, > or that is a bug in `YAHOO.lang'. Either way, it is nothing that requires > the attention of the the developer of the used library (that which contains > the code above). > YAHOO.lang.hasOwnProperty will fail when: 1) argument `o` has a property named "hasOwnProperty". One such object is YAHOO object. This could happen when calling: YAHOO.lang.augmentObject(YAHOO.lang, other) - though YAHOO.lang.augmentObject has much more serious problems, so it should be avoided. 2) Object.prototype.hasOwnProperty is supported and `o.hasOwnProperty` refers to something other than Object.prototype.hasOwnProperty. - if `o` is YAHOO.lang it looks like it will recurse infinitely. - if `o` is the global object then it can fail (and it will in many versions of Opera). 3) when `o.constructor.prototype` is not the [[Prototype]] of o. The case that is not very hard to fix is case (2): Object.prototype.hasOwnProperty is supported and `o.hasOwnProperty` refers to something other than Object.prototype.hasOwnProperty. The strategy to address that involves using `OP.hasOwnProperty.call(o, prop);`. To get it to work on global object, a simple patch can be used. -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/ |