You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/technologies/javascript/spread-operator.mdx
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,7 +97,9 @@ The spread operator isn't just limited to arrays in JavaScript; it can be used w
97
97
98
98
### Copying object properties
99
99
100
-
Take a look at the example below:
100
+
With the spread operator, you can copy the properties of an object into a new object. This is useful when creating a copy of an object without modifying the original object.
101
+
102
+
To copy an object using the spread operator, spread the original object inside a new object. Take a look at this example:
101
103
102
104
```js
103
105
constbook= {
@@ -119,11 +121,12 @@ console.log(bookInfo);
119
121
} */
120
122
```
121
123
122
-
In the example above, the `bookInfo` object copies the properties of the `book` object.
124
+
In the example above, the `bookInfo` object copies the properties of the `book` object by using the spread operator to copy the properties of the original `book` object into the `bookInfo` object.
123
125
124
126
### Merging objects properties
127
+
You can merge two or more objects into a single object using the spread operator (`...`). The spread operator provides a simple way to combine the properties of multiple objects into a single object without modifying the original objects.
125
128
126
-
Consider the following example:
129
+
To merge objects using the spread operator, spread each object inside curly braces `{}`. Consider the example below:
0 commit comments