Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Negative indexes with array.get(-1) and array.set(-1, value) #23

@Zarel

Description

@Zarel

.get(-1) and .set(-1, value) have gotten a lot of support in #5, but since it's a separate proposal (and hasn't gotten a response from @keithamus yet), I figure it probably deserves its own issue.

Summary of reasons to favor it:

  • they allow access to arbitrary distances from the end, not just the last value
  • they're consistent with Map
  • they don't use getters/setters, which are a bit too magical for my tastes (setters especially – setting a property shouldn't have any side effect other than setting that property)
  • they can be polyfilled in ES3 engines

@rauschma mentioned "I remember there were arguments against those methods, but forgot what they were", but I've yet to find any arguments against this idea.

Looking at the comments in #5, I count 17 people in support (3 comments and 14 other thumbs-ups) and no opposition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions