How does this function determine if a property exists on the prototype
?
function hasPrototypeProperty(object, name){
return !object.hasOwnProperty(name) && (name in object);
}
I am confused by two things:
What is the !
operator doing to the hasOwnProperty
method?
And while &&
seems to saying (name in object)
has to be true as well, I am kind of not sure...
I know hasOwnProperty
will only return true
if the property exists on a instance, but I read it still checks the prototype
, if so, what for? That seems like a strange thing to do if the instance is the only thing which matters?
Thanks in advance!