Please explain why this condition from the algorithm below fails to recognize if an object does not have a property:
!collection[i].hasOwnProperty[pre]
function truthCheck(collection, pre) {
function check(){
for(var i = 0; i<collection.length; i++){
if(collection[i][pre]== false || !collection[i].hasOwnProperty[pre] || Number.isNaN(collection[i][pre])){
return false;
}
}
return true;
}
return check();
}
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Thank you