-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Support array push notation in _.set #1315
Labels
Comments
Hmm, with that the problem of consistent behavior across path types rears its head. |
jasonLaster
added a commit
to jasonLaster/lodash
that referenced
this issue
Aug 13, 2015
This is a POC implementation for supporting negative indices. There are several performance regressions and shortcuts. Negative indices are a common pattern that make it easy for developers to get the last, 2nd-last, value in an array. The way the implementation was added, it'd have far reaching implications. ```js _.result(['a','b','c'], -3) //=> 'a' _.get(['a','b','c'], -2) //=> 'b' _.at(['a','b','c'], -1) //=> ['c'] ``` It's also possible to support a path push notation where `a[-0]` could indicate the array location after the last location. This was brought up by lodash#1315. ```js _.set({ a: [1] }, 'a[-0]', 2) //=> { a: [1, 2] } ``` @jridgewell and I paired on this.
Closed
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently when using set it will support the computed property notation so that I can go
This works great for turning a urlencoded form's input name into an object however it would be nice if the "push" notation was also valid (currently it does nothing).
By that I mean:
Is this possible? It would be pretty handy.
The text was updated successfully, but these errors were encountered: