Skip to main content

Spread Syntax

An interable like an array or string can be โ€œspreadโ€ into multiple function arguments or array elements.

function concat(a, b, c) {
return a + b + c;
}

const values = ["foo", "bar", "baz"];
console.log(concat(...values)); // 'foobarbaz'

const otherValues = ["bleep", ...values, "potato"];
assertEquals(["bleep", "foo", "bar", "baz", "potato"], otherValues);

Referencesโ€‹