Be careful - they won't produce the same result.
in
will also return true
if key
gets found somewhere in the prototype chain, whereas Object.hasOwnProperty
(like the name already tells us), will only return true
if key
is available on that object directly (its "owns" the property).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…