Pattern: Use of Array.from()
instead of spread operator
Issue: -
The spread operator (...
) provides a more concise and readable way to convert iterables to arrays compared to using Array.from()
. Use spread syntax when converting simple iterables to arrays.
Example of incorrect code:
const foo = Array.from(set);
const foo = Array.from(new Set([1, 2]));
Example of correct code:
[...set].map(() => {});
Array.from(...argumentsArray);