JS Built-ins
Operatorsintermediate

Operators β€” ... spread: merge arrays and objects

Spread operator expands iterables

... spreads the elements of an array or properties of an object inline.

Challenge: Write mergeAll(arr1, arr2, obj1, obj2) that returns:

  • arr: arr1 and arr2 merged into one array using spread
  • obj: obj1 and obj2 merged into one object using spread (obj2 properties win)
πŸ’‘ Hints (2)
  • β€’ [...a, ...b] spreads both arrays
  • β€’ { ...a, ...b } merges both objects (later props win)