When type checking variables to prevent app from crashing I always use
var hasBarProperty = foo.hasOwnProperty("bar");
However i recently added a new linting package and its throwing an error on that line saying the following line is better
var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, "bar");
When I click the error it shows this explanation which I do not fully understand,
So why is the second one better than the first?
Thanks