objhasOwnProperty
objhasOwnProperty, commonly referred to as hasOwnProperty, is a method on JavaScript objects that tests whether a given property exists as an own property (not inherited through the prototype chain). It returns true if the property is directly present on the object, and false if the property is inherited or absent.
The typical usage is obj.hasOwnProperty(prop) where prop is a string or symbol naming the property. For example,
To guard against shadowing, a robust form is Object.prototype.hasOwnProperty.call(o, key). This ensures the check uses the
As a modern alternative, ES2022 added Object.hasOwn(obj, prop), a static method that performs the same check