Uji apakah properti ada javascript
const hero = {
name: 'Batman'
};
hero.hasOwnProperty('name'); // => true
hero.hasOwnProperty('realName'); // => false
f0ru0l0rd
const hero = {
name: 'Batman'
};
hero.hasOwnProperty('name'); // => true
hero.hasOwnProperty('realName'); // => false
var person = {'first_name': 'bill','age':20};
if ( person.hasOwnProperty('first_name') ) {
//person has a first_name property
}
myObj.hasOwnProperty(myProp)