Spread Syntax
Use spread syntax in literals and function calls, plus shorthand struct keys.
📋 Table of Contents
🚀 Function call spread
Spread an array into positional arguments
function add( a, b, c ) {
return a + b + c
}
args = [ 1, 2, 3 ]
result = add( ...args ) // 6Spread a struct into named arguments
Inline literals
Works with more than plain function calls
📦 Array literal spread
🧱 Struct literal spread
Unordered struct literals
Ordered struct literals
Spreading arrays into structs
✨ Struct shorthand keys
🧪 Spread-only bracket literals
If the spread sources are arrays
If the spread sources are structs
🔁 Merge precedence
⚠️ Common errors
Non-spreadable values
Null spread values
Mixed spread-only bracket sources
✅ Summary
Last updated
Was this helpful?
