Element without properties

1

See the following code snippet below:

var element = document.getElementById('myDiv');

console.log('element: ', element);

console.log('has tagName property: ', element.hasOwnProperty('tagName'));
console.log('all properties: ', Object.getOwnPropertyNames(element));

console.log('tagName value: ', element.tagName);
<div id="myDiv"></div>

Notice that the element exists, but all attempts to check the properties of the element are unsuccessful. But in the end I usually get the value of the property that, according to the checks, should not exist.

According to the MDN documentation, the hasOwnProperty() only returns direct properties of the evaluated object. In this case should tagName property not be returned?

    
asked by anonymous 06.07.2018 / 02:37

0 answers