Consider:
if (someVar.hasOwnProperty('someProperty') ) {
// Do something();
} else {
// Do somethingElse();
}
What is the right use/explanation of hasOwnProperty('someProperty')
?
Why can't we 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?
Question&Answers:os