title: Javascript function indexOf returns incorrect results
body: <p>I have these two arrays:</p>
  
  <pre><code>array1 = ["a,1", "b,2", "c3", "d4", "e5", "f6"];
  array2 = [1, 2, 3, 4];
  </code></pre>
  
  <p>And I'm trying to find out if an element of the first array is in the second one.</p>
  
  <pre><code>for (i = 0; i &lt; array1.length; i++) { 
    if(array2.indexOf(array1[i][1]) != -1) {
      console.log('In array: '+array1[i][1]);
    } else {
      console.log('NOT in array: '+array1[i][1]);
  }
  </code></pre>
  
  <p>In this case, I always get the message <strong>NOT in array ..</strong>.</p>
  
  <p>But if I modify the code this way:</p>
  
  <pre><code>for (i = 0; i &lt; array1.length; i++) { 
    if(array2.indexOf(1) != -1) {
      console.log('In array: '+array1[i][1]);
    } else {
      console.log('NOT in array: '+array1[i][1]);
  }
  </code></pre>
  
  <p>The output is <strong>In array: ...</strong>.</p>
  
  <p>With a number as a parameter of the <strong>indexOf()</strong> function it's working, but no with the variable... how is that possible?</p>
  
  <p>Thank you</p>