codemix/fast.js — pull request #2 by DanielWeiner (2014-06-24 15:01:28+00:00)
Title: Update index.js

Array.forEach will only iterate over keys that exist. So for example, forEach will only iterate twice for [0,,,,,5], on elements 0 and 5. Likewise, take `var arr = [0,1,2]; delete arr[1]; arr.forEach(function(e){console.log(e);})`. The console output will be 0 and 2.

If you were to check if a value is undefined, you run into the same problem because you can have an array element that exists with an undefined value. forEach should iterate over that, but not over a nonexistent element.

Using Object.keys solves this problem.