includes
Object.keys(x).includes('y');
The Array.prototype.includes()
method determines whether an array includes a certain value among its entries, returning true or false as appropriate.
and
Object.keys()
returns an array of strings that represent all the enumerable properties of the given object.
.hasOwnProperty()
and the ES6+ .?
-optional-chaining like: if (x?.y)
are very good 2020+ options as well.