javascriptmethodsconsolehasownproperty

Why am I only getting back the results of my final 'hasOwnProperty' call?


I am just wondering why when I call the 'hasOwnProperty' method multiple times, I am only being returned one boolean value in the console? It is always the final call that returns. The rest of my code is fully functional and if I switch round the order I call to check on where the 3 properties are it returns whichever call came last.

spot.hasOwnProperty("sit");
spot.hasOwnProperty("name");
spot.hasOwnProperty("species"); 

Cheers guys.


Solution

  • They all return but the console just displays output of the latest command; You can put them in an array to see all responses at once

    [spot.hasOwnProperty('sit'), spot.hasOwnProperty('name')]