Rule proposal: `prefer-change-array-by-copy`
See original GitHub issue“Change Array by copy” proposal
Fail
array.reverse();
array.sort();
const array = [...foo];
array.splice(0, 1);
const array = [...foo];
array[1] = 'changed';
Pass
array = array.withReversed();
array = array.withSorted();
const array = foo.withSpliced(0, 1);
const array = foo.withAt(1, 'changed');
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Names of functions · Issue #10 · tc39/proposal-change-array ...
This proposal notably makes it easier to write code able to deal with Arrays and Tuples interchangeably. This strikes me as a non-argument. ......
Read more >Copy array of objects and make changes without modifying ...
I have an array of objects. I would like to deep copy the array of objects and make some changes to each object....
Read more >Proposed rule: Private Fund Advisers - SEC.gov
We propose to require registered investment advisers to private funds to provide transparency to their investors regarding the full cost of ...
Read more >ECMAScript proposal “Change Array by copy”: four new non ...
This blog post describes the ECMAScript proposal “Change Array by copy” by Robin Ricard and Ashley Claymore. It proposes four new methods ...
Read more >Array.prototype.remove - Ideas - TC39 - Discourse
EDIT : As noted below, it would be logical to include Array.prototype.insert in the proposal as well. 1 Like. ljharb May 3, 2021,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The proposal has updated, see https://github.com/tc39/proposal-change-array-by-copy/commit/752e576db3d55e9d1d80a97df1f1e54c26ffbd7f
withReversed
->toReversed
withSorted
->toSorted
withSpliced
->toSpliced
withAt
->with
One pattern that I’ve been using is to clone arrays in the function parameters and I hope it can be preserved. I think the same thing applies to array destructuring.
Before
After