How can I determine whether an object x
has a defined property y
, regardless of the value of x.y
?
I’m currently using
if (typeof(x.y) !== 'undefined')
but that seems a bit clunky. Is there a better way?
How can I determine whether an object x
has a defined property y
, regardless of the value of x.y
?
I’m currently using
if (typeof(x.y) !== 'undefined')
but that seems a bit clunky. Is there a better way?