Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: hasOwnProperty and property className Date: Sun, 02 Apr 2017 00:39:41 +0200 Organization: PointedEars Software (PES) Lines: 56 Message-ID: <1898070.irdbgypaU6@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1491086381 1301 eJwFwYEBwCAIA7CXFNo6zgGU/09YQtdWH4gChzO3i3Ci/PBs26HBpK1qpJ7w7rLPWS/CsusHGesRLA== (1 Apr 2017 22:39:41 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 1 Apr 2017 22:39:41 +0000 (UTC) User-Agent: KNode/4.14.2 X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. […] Evertjan. wrote: >> Cezary Tomczyk […] wrote […]: >>> Just out of curiosity. >>> >>> Why document.body.hasOwnProperty('className') returns false? >>> >>> Property className does exists for object document.body object. >> >> hasOwnProperty() >> is about Javascript-objects, >> not about DOM-objects, >> methinks. >> […] > > Thanks. For misinformation based on a jump to conclusion based on cluelessness? > On MDN > https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty > documentation doesn't mentioned that specifically. And there is no reason why it should. > Just: > > "The hasOwnProperty() method returns a boolean indicating whether the > object has the specified property." That wording is not entirely correct or, IOW, it is ambiguous; a matter of definition. In ECMAScript wording, an object has a property if it has the property itself (its *own* property) *or* inherits the property from another object through the prototype chain. (The inheritance is implicit; if you attempt to access a property of an object that does not have it as its own, lookup proceeds along the prototype chain until an object that has that property as its own or the end of the prototype chain is reached.) And that is definitely _not_ what the has*Own*Property() method’s return value indicates. I have clarified the wording in the article accordingly. > That's why I was asking. Too bad then that you have not read carefully the “Description” section of the article (which clarified that even before my edit), and my explanation in my other follow-up. -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.