title: Why is my object property undefined when using it in a if-statement?
body: <p>I am trying to search in an array via for loop</p>
  
  <pre><code>      let matrix = [];
        for(let i=0; i&lt;this.row; i++){
          for(let j=0; j&lt;this.column; j++){
              if(this.grid[i][j].name != ""){
                matrix.push(this.grid[i][j].name);
                console.log(matrix);
              }
          }
  </code></pre>
  
  <p>but it does not work. I get the error that <code>this.grid[i][j].name</code> is <code>undefined</code> although this would work perfectly: </p>
  
  <pre><code>      let matrix = [];
        for(let i=0; i&lt;this.row; i++){
          for(let j=0; j&lt;this.column; j++){
              if(this.grid[i][j]){
                matrix.push(this.grid[i][j].name);
                console.log(matrix);
              }
          }
  </code></pre>
  
  <p>I ask whether there is an object and if there is one, then push the name property into the variable <code>matrix</code> and here strangely the property <code>this.grid[i][j].name</code>is correctly defined but why is it not defined using the property in the if statement?</p>