Spread syntax feels more confusing than its worth.
Introduced in ES6, and greatly over-shone by const and let, spread is an intriguing creature.
The confusion spread causes may be due to the fact that it functions differently for objects and arrays.
In fact, the spread parameter functions in the exact opposite manner for objects.
Rest syntax looks exactly like spread syntax. In a way, rest syntax is the opposite of spread syntax. Spread syntax "expands" an array into its elements, while rest syntax collects multiple elements and "condenses" them into a single element.
Spread syntax (...)
For arrays, the case for spread isn’t clear either.
Is `sum(…numbers)` more readable than sum(1, 2, 3)?
// array spread
function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(...numbers));
// expected output: 6
Other News
Stenography passed $40/MRR today. My costs are roughly ~$15/mo currently to run it, so I’m officially in the black!
ars longa, vita brevis
Bram
Didn't even link roon's post, how could you do that to your fellow wordcel who programs? 😂