Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Use square brackets to specify an array index instead of assuming numbers as indexes #96

Open
mariocasciaro opened this issue Mar 23, 2018 · 3 comments

Comments

@mariocasciaro
Copy link
Owner

No description provided.

@jjt
Copy link

jjt commented Sep 6, 2018

This would be great. Not only does it match how you would access an actual JS object (socialGraph.users[0]), but libs like Formik use this notation as well for its paths.

@revelt
Copy link

revelt commented Oct 22, 2019

to add 2p., bracket notation could be used interchangeably and also, it could be used to escape dots in key names — if you pass a[0] you mean { a: [x] } but if you pass string, it means it's escaped object key name — a["b.c"] means {a: { "b.c": "x" }}

@vitaly-t
Copy link

vitaly-t commented Dec 7, 2020

Numbers as indexes - that's the natural way of resolving array elements, i.e. natural because properties-numbers are treated as indexes directly, without any extra work.

Adding support for [] isn't just an extra parsing, but a heavy one, with most likely use of RegEx. As a result, it will be quite an impact on performance.

P.S. My tests showed this library is already quite slow as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants