Skip to content

each vs each-in #1100

Open
Open

Description

@NullVoxPopuli

See existing behavior of each vs each-in

Is there a good reason to not have each just... do everything?

  • handle non-arrays (call .entries() or Object.entries())
  • continue to yield out the index as the last param (each-in does not do this)

Activity

  1. void-mAlex commented on May 8, 2025

    @void-mAlex
    Contributor

    just the same reasoning you don't have .forEach on Object
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
    they are different, do different things as you pointed out one of them doesn't have indexes you can pretend it does, but only a derived state like entries has them as that is not guaranteed to be stable
    other examples for..in and for..of they are separate things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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