Javascript what is property in hasOwnProperty?
if (someVar.hasOwnProperty('someProperty') ) { // do something(); } else { // do somethingElse(); } What is the right use/explanation of hasOwnProperty('someProperty') ? Why we can't simply use someVar.someProperty to check if an object someVar contains property with name someProperty ? What is a property in this case? What property does this javascript check? hasOwnProperty returns a boolean value indicating whether the object on which you are calling it has a property with the name of the argument. For example: var x = { y: 10 }; console.log(x.hasOwnProperty("y")); //true console.log(x