title: JavaScript For loop vs for in does not work
body: <p>I wrote two functions named some and every to expect to get results shown as below:</p>
  
  <pre><code>console.log(every([NaN, NaN, NaN], isNaN));
  // → true
  
  console.log(every([NaN, NaN, 4], isNaN));
  // → false
  
  console.log(some([NaN, 3, 4], isNaN));
  // → true
  
  console.log(some([2, 3, 4], isNaN));
  // → false
  </code></pre>
  
  <p>My functions are:</p>
  
  <pre><code>function every(array,predicate){
    for (var element in array){
      if (!predicate(element))
        return false;
    }
    return true;
  }
  
  function some(array, predicate){
    for (var element in array){
      if (predicate(element))
        return true;
    }
    return false;
  }
  </code></pre>
  
  <p>But the results are all <code>false</code></p>
  
  <p>Once I change the <code>for...in</code> to <code>for</code> loop, the answers are correct.</p>
  
  <pre><code>function every(array, predicate) {
    for (var i = 0; i &lt; array.length; i++) {
      if (!predicate(array[i]))
        return false;
    }
    return true;
  }
  
  function some(array, predicate) {
    for (var i = 0; i &lt; array.length; i++) {
      if (predicate(array[i]))
        return true;
    }
    return false;
  }
  </code></pre>
  
  <p>Why <code>for..in</code> can not result in the correct answer?</p>