Check Key Exists

You can check whether a certain key exists in an object with the hasOwnProperty method.

const obj = { greeting: 'hello world' };

obj.hasOwnProperty('greeting');
// => true

obj.hasOwnProperty('age');
// => false

Backlinks