AI

Arrays are reference types! If you assign arr1 = arr2, they point to the same list. Use [...arr] to make a real copy.

Your Task:

  • Create referenceCopy = originalItems
  • Create spreadCopy = [...originalItems]
  • Add "New Item" to all 3 arrays (original, reference, spread) using push
  • Notice how original and reference stay in sync?
TypeScript Solution
Loading...

Submit your code to see test results