Object.assign() method
JavaScript Object.assign() Method
Last Updated : 17 Mar 2025
The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. Objects are assigned and copied by reference. It will return the target object.
Syntax:
Parameter
target: The target object.
sources: The source object(s).
Return value:
This method returns the target object.
Browser Support:
| Chrome | Yes |
| Edge | Yes |
| Firefox | Yes |
| Opera | No |
Example 1
Output:
3 5 1 2
Example 2
Output:
33 5
Example 3
Output:
3 5 23 1
Next TopicJavaScript Objects