javascript check if object property exists

JavaScript
if (obj.hasOwnProperty('prop')) {
    // do something
}var person = {'first_name': 'bill','age':20};

if ( person.hasOwnProperty('first_name') ) {
    //person has a first_name property
}
myObj.hasOwnProperty(myProp)const hero = {
  name: 'Batman'
};

hero.hasOwnProperty('name');     // => true
hero.hasOwnProperty('realName'); // => falseif ('field' in obj) {
}

Source

Also in JavaScript: