How to check if a particular key exists in a JavaScript object or array?

if you want to particularly test for properties of the object instance (and not inherited properties), use hasOwnProperty:

obj.hasOwnProperty("key") // true

Published: January 10 2018

blog comments powered by Disqus