Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32901

Re: hasOwnProperty and property className

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: hasOwnProperty and property className
Date 2017-04-02 00:39 +0200
Organization PointedEars Software (PES)
Message-ID <1898070.irdbgypaU6@PointedEars.de> (permalink)
References <obnrdm$158t$1@csiph.com> <XnsA74A7CF5916ADeejj99@194.109.6.166> <obobnk$1hpt$1@csiph.com>

Show all headers | View raw


Cezary Tomczyk wrote:

> […] 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: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

hasOwnProperty and property className Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-04-01 11:20 +0200
  Re: hasOwnProperty and property className "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-01 12:17 +0200
    Re: hasOwnProperty and property className Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-04-01 15:59 +0200
      Re: hasOwnProperty and property className "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-01 16:40 +0200
      Re: hasOwnProperty and property className Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-02 00:39 +0200
  Re: hasOwnProperty and property className Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-01 13:53 +0200

csiph-web