Please use this tag to refer to "..." (spread) syntax in JavaScript. Do not use for R language "spread" function, use [spread] instead. The spread syntax allows an iterable such as an array expression or string to be expanded in places where arguments for function calls, elements for array literals, or key-value pairs for object literals are expected.
Usage guidance
Use for questions about the ...
(spread) syntax in ECMAScript.
Do not use for R language spread
function, use spread instead.
About
Spread is a syntax added in ES6 allowing for substituting an iterable where a list of elements (e.g. in a function call) is expected:
(() => {
const print = (q, a) => console.log(`-${q}? -${a}`);
print(...["*", 42]); // spread in arguments
const concat = (a, b) => [...a, ...b];
concat([1,2],[3,4]); // spread in arrays
})();
The spread syntax is also used in spread properties, a TC39 proposal that is a part of ECMAScript since 2018 allowing own enumerable properties of an object to be copied to another in a concise manner:
(() => {
const A = { answer: 42 };
const Q = { question: "?" };
const QnA = { ...A, ...Q };
console.log(QnA.question); // "?"
console.log(QnA.answer); // 42
})();