In my JavaScript code I have a function which contains following set of statements
function someFunc(object,action){
for(var property in object){
if(Object.prototype.hasOwnProperty.call(object, property)){
//TODO
}
}
}
}
and If I replace if statement inside function with
if(obj.hasOwnProperty(property)){
//TODO
}
both are working fine for me. All I want to know is that which among them is better approach and why? I know that obj.hasOwnProperty(property)
check for the personal property of the object. I also want to know how call is chaining up here
object.prototype.hasOwnProperty.call(object, property)