objhasOwnPropertypropertyName
hasOwnProperty is a method in JavaScript used to check whether a given object has a property as its own (not inherited through the prototype chain). It is defined on Object.prototype, so any object inherits it, but its result depends on whether the property exists directly on that object rather than on its prototype.
In practice, obj.hasOwnProperty(prop) returns true if obj has a direct property named prop. It returns false
Care is needed when obj is null or undefined, as calling hasOwnProperty on such values will throw
Since ES2022, a static method Object.hasOwn(obj, prop) provides a similar capability without relying on an object's
Overall, hasOwnProperty remains a fundamental tool for distinguishing direct properties from inherited ones, with a safe