cara memeriksa apakah properti ada di objek dalam skrip java
if (obj.hasOwnProperty('prop')) {
// do something
}
Expensive Eland
if (obj.hasOwnProperty('prop')) {
// do something
}
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
}