Periksa properti objek ada atau tidak di JS

const user1 = {
	username: "john"
};
const user2 = {
	username: "duo"
    authority: "grepper"
}
// check object property
console.log(user1.hasOwnProperty('authority')); // false
console.log(user2.hasOwnProperty('authority')); // true
Easy Earthworm