Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 516 Bytes

prefer-spread.md

File metadata and controls

21 lines (15 loc) · 516 Bytes

Pattern: Use of Array.from() instead of spread operator

Issue: -

Description

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.

Examples

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);