Path: csiph.com!.POSTED.204-73-239-109.cust.centrio.cz!not-for-mail From: Cezary Tomczyk Newsgroups: comp.lang.javascript Subject: Re: hasOwnProperty and property className Date: Sat, 1 Apr 2017 15:59:14 +0200 Organization: csiph.com Internet News Service Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 1 Apr 2017 13:59:16 +0000 (UTC) Injection-Info: csiph.com; posting-host="204-73-239-109.cust.centrio.cz:109.239.73.204"; logging-data="51005"; mail-complaints-to="admin@kev009.com" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: csiph.com comp.lang.javascript:32896 On 01/04/2017 12:17, Evertjan. wrote: > Cezary Tomczyk wrote on 01 Apr 2017 in > comp.lang.javascript: > >> 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. > > var a = []; // an array > document.write( a.hasOwnProperty('length') ); // true > document.write( '
' ); > > document.write( document.body.hasOwnProperty('style') ); // false > document.write( '
' ); Thanks. On MDN https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty documentation doesn't mentioned that specifically. Just: "The hasOwnProperty() method returns a boolean indicating whether the object has the specified property." That's why I was asking. -- Cezary Tomczyk http://www.ctomczyk.pl/