Skip to content Skip to sidebar Skip to footer

Why Hasownproperty Returns True

This question is an extension of Can't understand the behavior of deleting vars in JavaScript This is happening on Google Chrome:- CASE 1: var x = 5; window.x === x // true. x, as

Solution 1:

Let me to use my answer:

You create variable in global scope by var, not property of window object. This var is just linked to window.x. And then you compare window.x === x it will return true.

Also object.hasOwnProperty(x) check what object has x as property (via object.x) not x from prototype chain.

Post a Comment for "Why Hasownproperty Returns True"