how to check if object has key javascript

JavaScript
myObj.hasOwnProperty('key') // it checks object for particular key and not on prototype   "key" in obj // true, regardless of the actual valueObject.prototype.hasOwnProperty()if ('key' in myObj)if ('key' in myObj)
// better
if (!myObj.hasOwnProperty('key'))
Source

Also in JavaScript: