// JavaScript does not protect hasOwnProperty method
var foo = {
// overriding foo's default hasOwnProperty method
hasOwnProperty: function() {
return false;
},
bar: 'data'
};
foo.hasOwnProperty('bar'); // false always
// Hence, to prevent this, use Object.prototype.hasOwnProperty as follows-
Object.prototype.hasOwnProperty.call(foo, 'bar'); // true