Use Spread Syntax (...) instead of '.apply'

The spread syntax (...) allows iterables like array expressions to be expanded in place where arguments are expected. It can used in place of .apply. For example Math.min.apply(Math, args) can be replaced with Math.min(...args).

Original Code

Changes

11const items = [1, 2, 3];
22const container = [];
3container.push.apply(container, items);
3container.push(...items);

Transformed Code

const items = [1, 2, 3];
const container = [];
container.push(...items);

Explore More