The hasOwnProperty method, as the name implies, take a look at the object to see if it has its property.
But when you use the 'propertyName' in test , you not only look at the object’s own properties, but also the properties that come from inheritance.
In this case, the constructor is a property that is inside the Object , so all objects have this property, because they all inherit from Object .
Quote from MDN
Each object generated from Object inherits the hasOwnProperty method. This method can be used to determine whether an object has the specified property as a direct property of this object; unlike the in operator , this method does not test the prototype of the circuit object.
source share