This is my object data:
[{id:1, name:"Cat", category:{id:2, name:"Animals"}}]
I want to check if it contains the key category.
This is my approach:
if (data.hasOwnProperty("category")) {
console.log("data contains category");
}else {
  console.log("data does not contain category");
}
The output is:
data does not contain category
Should be the opposite...
 
     
     
     
    