Skip to content
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
@runemoennike

Description

@runemoennike

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions