You are developing a function that needs to merge two objects, with the second object overwriting the properties of the first one if there is a conflict. How would you achieve this?

  • Object.assign()
  • Object.merge()
  • Object.combine()
  • Object.extend()
To merge two objects with property conflicts, you can use the Object.assign() method. It takes one or more source objects and copies their properties to a target object. If properties with the same name exist in the target object, they will be overwritten by the source object's properties.
Add your answer
Loading...

Leave a comment

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