Comment vérifier si l'objet a un javascript clé
myObj.hasOwnProperty('key') // it checks object for particular key and not on prototype
Proud Pony
myObj.hasOwnProperty('key') // it checks object for particular key and not on prototype
if ('key' in myObj)
// better
if (!myObj.hasOwnProperty('key'))
if ('key' in myObj)
if (myObj['key']) {
// Do something
}
Object.prototype.hasOwnProperty()
console.log("key" in obj)