👨‍💼 Excellent! You've mastered the ... operator in both its forms.
You learned:
  • 📤 Array spread - Expand arrays: [...arr, newItem]
  • 📦 Object spread - Expand objects: { ...obj, newProp: value }
  • 📥 Rest parameters - Collect arguments: function fn(...args)
  • 🔄 Immutable updates - Create new objects/arrays instead of mutating
🦉 The key distinction:
ContextNameEffect
[...arr]SpreadExpands into elements
{ ...obj }SpreadExpands into properties
fn(...arr)SpreadExpands as function args
function fn(...x)RestCollects args into array
const [a, ...rest]RestCollects remaining elements
const { a, ...rest}RestCollects remaining props
These patterns are foundational for:
  • React state updates
  • Redux reducers
  • Utility functions
  • Any immutable data manipulation
You're now equipped to write modern, immutable TypeScript code! 🎉
Loading Spread and Rest Operators Elaboration form