This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
The behaviour of forEach has changed to now iterate also over skipped numeric keys. #8522
Closed
Description
As of 1.2.21 (possibly before) forEach behaves differently to what it did in 1.2.18. Given an object with numeric keys, where some numbers are skipped, it now iterates also over those missing keys, so to speak.
The following code:
var input = [], output = [];
input[1] = "a";
input[3] = "b";
input[5] = "c";
angular.forEach(input, function (v) {
output.push(v);
})
console.log(output);
Produces an output of ["a", "b", "c"]
in 1.2.18 while in 1.2.21 now gives [undefined, "a", undefined, "b", undefined, "c"]
.
Browser: Chrome 36
OS: Windows 8
Is this intentional? I noticed it because it breaks the angular-strap datepicker.
Metadata
Metadata
Assignees
Labels
No labels