samedi 14 juillet 2018

Check if category along with key exists in 1 if? [duplicate]

This question already has an answer here:

So, i want to check if object.category.key exists.

What i mean is that, i want to do something like that:

if(obj.category) {
   if(obj.category.key) {

   }
}

But with 1 if instead of 2 or 3 or 5?

Code i tried:

if(("key" in obj.category)) {

}

But i get Uncaught TypeError: Cannot use 'in' operator to search for 'key' in undefined

Aucun commentaire:

Enregistrer un commentaire