#190·es5-shim

forEach/map do not iterate over undefined values in IE 6-8

Author: ljharbCreated Dec 19, 2013Updated Feb 6, 2017
LabelsES3 browsersIE 6-8 undefined as sparse array issue

var a = [undefined]; a.map(function (v) { return v; }).length === a.length => true, which is good.

However, var a = [undefined], b = []; a.forEach(function (v) { b.push(v); }); b.length === a.length => false, which is bad (In Safari, for example, it gives true)

update: 0 in [undefined] returns true for most browsers but false in IE 6-8, which is the root of the issue.