title: Javascript if statement not executing code
body: <p>I have a pretty simple code that checks if the items in an array are contained in another. If they are, I push into the <code>itens</code> array an input checked checkbox, if they are not, I push a regular unchecked checkbox to the array. Check it out:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$.ajax({
    url: '${pageContext.request.contextPath}/filial/select.json',
    method: 'GET'
  }).done(function(json) {
    var itens=[];
    var filiaisSelecionadas = ${filiais};
    for (var i = 0; i &lt; json.length; i++) {
      if(filiaisSelecionadas.includes(json[i])) {
     itens.push('&lt;input id= "idFilial'+json[i][0]+'" type = checkbox class=checkbox1 name = filiaisId value="'+json[i][0]+'" checked&gt;' +json[i][1]+"-"+ json[i][2]  + '&lt;/input&gt;&lt;/br&gt;');
   } else {
        itens.push('&lt;input id= "idFilial'+json[i][0]+'" type = checkbox class=checkbox1 name = filiaisId value="'+json[i][0]+'"&gt;' +json[i][1]+"-"+ json[i][2]  + '&lt;/input&gt;&lt;/br&gt;');
   }
    }
    $('#idFilial').html($("&lt;tbody/&gt;", {html:itens}));
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But for some reason the code inside the <code>if(filiaisSelecionadas.includes(json[i]))</code> just doesn't execute. The treatment works just fine. If the item isn't in the array it pushes the unchecked checkbox. However if the item IS in the array, it just doesn't execute? I would understand if it always executed the else statement, but not executing neither???? This confuses de b'jesus out of me...</p>
  
  <p>Edit: The <code>filiaisSelecionadas</code> (that gets filled with the <code>${filiais}</code> EL)is an array of an object that has a bunch of properties. The Json returned is an array of the same objects, but doesn't contain the same exact objects as the other. The json array is always either bigger or the same size as <code>filiaisSelecionadas</code>.</p>
  
  <p>Edit 2: By request of user Hongarc I added <code>console.log()</code> to if and else, the result is as follows:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$.ajax({
    url: '${pageContext.request.contextPath}/filial/select.json',
    method: 'GET'
   }).done(function(json) {
    var itens=[];
    var filiaisSelecionadas = ${filiais};
    for (var i = 0; i &lt; json.length; i++) {
     if(filiaisSelecionadas.includes(json[i])){
      console.log("The IF statement is executing!");
      itens.push('&lt;input id= "idFilial'+json[i][0]+'" type = checkbox class=checkbox1 name = filiaisId value="'+json[i][0]+'"&gt;' +json[i][1]+"-"+ json[i][2]  + '&lt;/input&gt;&lt;/br&gt;');
     }
     else{
      console.log("The ELSE statement is executing!\"");
      itens.push('&lt;input id= "idFilial'+json[i][0]+'" type = checkbox class=checkbox1 name = filiaisId value="'+json[i][0]+'"&gt;' +json[i][1]+"-"+ json[i][2]  + '&lt;/input&gt;&lt;/br&gt;');
     }
    }
     $('#idFilial').html($("&lt;tbody/&gt;", {html:itens}));
  
    });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>with the output being
  <a href="https://i.stack.imgur.com/aw5q5.png" rel="nofollow noreferrer">two lines of "The ELSE statement is executing!"</a></p>
  
  <p>Mind that my json array has size 4 and for the test I made it so it would hold 2 objects that are in the other array and 2 that aren't. So the espected output should have been "The IF statement is executing!" x2 and  "The ELSE statement is executing!" x2.</p>