Skip to content

no-useless-spread it is not safe to remove spread in [...foo.concat(bar)] #2480

@magic-akari

Description

@magic-akari

'[...foo.concat(bar)]',

Note

The concat() method preserves empty slots if any of the source arrays is sparse.

via MDN

const foo = new Array(5);
const bar = new Array(5);

const cat = [...foo.concat(bar)];
// now we got a new array with undefined x 10
// but foo.concat(bar) is empty x 10.
// It's not what we want.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions