check if property name exists javascript code example
Example 1: check if js property exists in class
myObj.hasOwnProperty(myProp)
Example 2: test if property exists javascript
const hero = {
name: 'Batman'
};
hero.hasOwnProperty('name'); // => true
hero.hasOwnProperty('realName'); // => false