Rule proposal: `Array#push` + rest parameter instead of `Array#concat`
See original GitHub issueJust a minor suggestion, not sure if it’s actually any better or preferred. Maybe:
array
can be aconst
- no repetition
- shorter
- could also partially cover https://github.com/eslint/eslint/issues/14581
Fail
array = array.concat(otherArray);
Pass
array.push(...otherArray);
Real-life example https://github.com/xojs/xo/pull/538/commits/31068d46f40e77302921dfad8b218426a3ebefec
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Why use `concat` instead of `push` in this instance?
If some other code has a reference to the existing array in actionQueue , using concat will not affect that.
Read more >Javascript Array.push is 945x faster than Array.concat - DEV ...
Javascript Array.push is 945x faster than Array.concat ... fastest method to merge arrays is to use .push which accepts n arguments:.
Read more >airbnb/javascript: JavaScript Style Guide - GitHub
Use the object rest parameter syntax to get a new object with certain ... 4.2 Use Array#push instead of direct assignment to add...
Read more >JavaScript Tutorial: The Basics
ECMAScript 2018 (ES9): Added rest parameters ( ... ), spread operator, asynchronous iteration, additions to regular expression.
Read more >eslint-config-ariporad - npm
`let` is block-scoped rather than function-scoped like `var`. ... Plus, rest arguments are a real Array, and not merely Array-like like ...
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
Could this be part of the error message, without an autofix?
Javascript Array.push is 945x faster than Array.concat 🤯🤔