🔰spread operator (...)
[...iterable], {...obj}, f(...iterable).
Last updated
Was this helpful?
[...iterable], {...obj}, f(...iterable).
Last updated
Was this helpful?
Was this helpful?
JS ⟩ statement ⟩ expression ⟩ operator ⟩ spread
adds all enumerable own properties of an object to an object literal.
f(...iterable) // spread arguments
[...iterable, 1, 2, 3] // spread elements
{...obj, key: 'value'} // spread properties ⭐️
⚠️ spread operator (...) is not a true operator, it cannot be evaluated to produce a value❗ (👉 table of operators)
...obj only spreads enumerable own properties, 👉 property enumeration.
can be used to assign default values instead of using Object.assign().
spread operator (...)
can be used in an .
"spreads out" an into array elements or function arguments.
ℹ️ punctuators used: