Skip to content

Commit e200f1d

Browse files
authored
Update spread-operator.mdx
1 parent 83310d8 commit e200f1d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/technologies/javascript/spread-operator.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ The spread operator isn't just limited to arrays in JavaScript; it can be used w
9797

9898
### Copying object properties
9999

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:
101103

102104
```js
103105
const book = {
@@ -119,11 +121,12 @@ console.log(bookInfo);
119121
} */
120122
```
121123

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.
123125

124126
### 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.
125128

126-
Consider the following example:
129+
To merge objects using the spread operator, spread each object inside curly braces `{}`. Consider the example below:
127130

128131
```js
129132
const info1 = {

0 commit comments

Comments
 (0)