HasOwnProperty goal


Does someone can explain what's the goal of this code ?

var hasOwn = Object.prototype.hasOwnProperty("hasOwnProperty");

It looks like it can be only useful in this case. I feel confused about it...

Thanks my codemates! :relaxed:


That will check if the Object() object has the "hasOwnProperty" method using itself.


@ijulian28, from MDN - Object.prototype.hasOwnProperty()

The hasOwnProperty() method returns a boolean indicating whether the object has the specified property.


Every object descended 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 that object;

In console you can check that Object() has property hasOwnProperty:

That's why

console.log(hasOwn); // true.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.