JavaScript Object.assign() Method

18 Mar 2025 | 1 min read

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:

ChromeYes
EdgeYes
FirefoxYes
OperaNo

Example 1

Output:

 3 5 1 2 

Example 2

Output:

 33 5 

Example 3

Output:

 3 5 23 1