How does the spread operator behave when used with JavaScript objects that have the same properties?

  • It merges the properties, with the values of the second object overwriting the values of the first object.
  • It throws an error because objects with the same properties cannot be spread.
  • It combines the properties into an array.
  • It creates a new object with the properties of the first object only.
When the spread operator (...) is used on objects with the same properties, it merges the properties, with the values of the second object overwriting the values of the first object. This behavior is known as object property spreading.
Add your answer
Loading...

Leave a comment

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