object has propert js code example Example: object contains property javascript if (x.hasOwnProperty('y')) {} //or if ('y' in x) {} //or if (x?.y){}