4.
What is the purpose of the Object.prototype.hasOwnProperty() method in JavaScript?
It is used to create a new object with a specific prototype.
It is used to retrieve the prototype object of an object.
It is used to check if an object has a specific property.
It is used to assign a new value to a property of an object.
Correct: C
The Object.prototype.hasOwnProperty() method is used to check if an object has a specific property. It returns a boolean value indicating whether the object has the property directly on itself (not on its prototype chain). This method can be used to avoid accessing properties inherited from the prototype chain.