How can I determine whether an object x
has a defined property y
, regardless of the value of xy
?
(如何确定对象x
是否具有已定义的属性y
,而不管xy
的值是多少?)
I'm currently using
(我正在使用)
if (typeof(x.y) !== 'undefined')
but that seems a bit clunky.
(但这似乎有点笨拙。)
Is there a better way?(有没有更好的办法?)
ask by translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…