Opposite of hasOwnProperty - Everything Be True

Opposite of hasOwnProperty - Everything Be True
0

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

hasOwnProperty is a function, not an array. You need to call it with parentheses, not brackets.

I wonder about this. What if I have an object:

const myObject = {
    share: false
}

myObject.hasOwnProperty('share') would return true, but your first check if(myObject.share == false || ...) would not pass.

Yes, I figured this out after posting this. It’s better to use Boolean(argument) to check for falsey values.
Thank you