How can the spread operator be used to create a shallow copy of an object in ES6?

  • Object.assign({}, originalObject)
  • originalObject.clone()
  • originalObject.spread()
  • Object.copy(originalObject)
The spread operator (...) can be used to create a shallow copy of an object by spreading its properties into a new object literal. Object.assign({}, originalObject) is a common pattern for creating a shallow copy in ES6.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *