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.

A syntax approach (arr[^n] for arr[arr.length-n]) #28

@caub

Description

@caub
  • more powerful (one syntax for many cases: arr[^1], arr[^2], etc.. or arr[~1] if this symbol is chosen)
  • more portable (it could apply to strings, we could use or not a protocol Symbol.index, I'm not sure it's needed, less spec additions is better)
  • more readable (similar to git shortcuts, C# also has a similar syntax, etc.)
  • no web compat risks
  • less complexity added (this proposal adds lastIndex and lastItem) and prototypes 'pollution', so
    a symtax approach is more future-proof in that aspect maybe?
  • goes well with another stage1 proposal slice-notation or slice-expression as it could be renamed, it was mentioned in Slice Extensibility proposal-slice-notation#19 (comment)

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