Skip to content

Commit e69671f

Browse files
committed
Release v1.0.32 - JS Spread Operator
1 parent 68df64e commit e69671f

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [1.0.32] 2023-05-10
4+
### Changes
5+
6+
- Update [JavaScript](https://docs.appseed.us/technologies/javascript/) Section
7+
- [Spread Operator](https://docs.appseed.us/technologies/javascript/spread-operator/)
8+
39
## [1.0.31] 2023-05-08
410
### Changes
511

docs/technologies/javascript/spread-operator.mdx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import SubHeading from "@site/src/components/SubHeading";
99
How to Use the Spread Operator (…) in JavaScript
1010
</SubHeading>
1111

12-
The spread operator is a powerful JavaScript feature introduced in ECMAScript 6 (ES6) and denoted by three dots (`...`). It expands the values of an iterable (such as an array, string, or object) to enable you to access and manipulate the iterable.
12+
The spread operator is a powerful JavaScript feature introduced in ECMAScript 6 (ES6) and denoted by three dots (`...`).
13+
It expands the values of an iterable (such as an array, string, or object) to enable you to access and manipulate the iterable.
1314

1415
Whether you're a beginner or an experienced JavaScript developer, learning how to use the spread operator is an essential skill that will take your coding to the next level.
1516
In this article, we'll explore the ins and outs of the spread operator and show you how to use it to write cleaner, more efficient code. So, let's get started!
1617

17-
## Using the spread operator in JavaScript arrays
18+
<br />
19+
20+
## Using the `Spread Operator` in Arrays
1821

1922
The spread operator is commonly used in JavaScript to expand the elements of an array. In this section, you'll learn how to concatenate and copy arrays using the spread operator.
2023

@@ -25,7 +28,9 @@ console.log(arrValue); //👉 Output: [ 'Hello', 'JavaScript' ]
2528
console.log(...arrValue); //👉 Output: Hello JavaScript
2629
```
2730

28-
### Concatenation
31+
<br />
32+
33+
### 👉 Concatenation
2934

3035
Concatenation is the process of joining two or more arrays to create a new large array. In JavaScript, you can concatenate arrays using the spread operator (`...`).
3136

@@ -41,7 +46,9 @@ console.log(merged); //👉🏻 Output: ['a', 'e', 'i', 'o', 'u', 'b', 'd', 'f']
4146

4247
From the code snippet above, there are two arrays - `vowels` and `random`. They are merged into one, called `merged` - containing all the elements of the arrays.
4348

44-
### Copying an array
49+
<br />
50+
51+
### 👉 Copying an Array
4552

4653
The spread operator provides a convenient way to copy an array into another array. It is useful when you want to manipulate an array without affecting the original array.
4754

@@ -71,7 +78,9 @@ console.log(newArray); //👉🏻 [ 'a', 'e', 'i', 'o' ]
7178

7279
The `newArray` variable creates a reference to the `vowels` variable instead of copying the entire array value.
7380

74-
## Using the spread operator in JavaScript functions
81+
<br />
82+
83+
## Using the `Spread Operator` in Functions
7584

7685
The spread operator can be used to accept an array of parameters in JavaScript functions; in this case, it is called the Rest Operator. It captures any number of arguments passed to the function and groups them into an array.
7786

@@ -86,16 +95,20 @@ function sumNumbers(...args) {
8695
console.log(sum);
8796
}
8897

89-
sumNumbers(1, 2, 3, 4, 5, 6, 7, 8, 9); //👉🏻 Output: 45
98+
sumNumbers(1, 2, 3, 4, 5, 6, 7, 8, 9); // 👉🏻 Output: 45
9099
```
91100

92101
In the example above, the function `sumNumbers` accepts an array of numbers with an undefined length using the rest operator, then loops through the arguments to add each number together and log the result to the console.
93102

94-
## Using the spread operator in JavaScript objects
103+
<br />
104+
105+
## Using the `Spread Operator` in Objects
95106

96107
The spread operator isn't just limited to arrays in JavaScript; it can be used with objects to execute tasks such as copying, merging, and updating object properties.
97108

98-
### Copying object properties
109+
<br />
110+
111+
### 👉 Copying Object Properties
99112

100113
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.
101114

@@ -123,7 +136,9 @@ console.log(bookInfo);
123136

124137
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.
125138

126-
### Merging objects properties
139+
<br />
140+
141+
### 👉 Merging Objects Properties
127142

128143
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.
129144

@@ -151,7 +166,9 @@ console.log(bookInfo);
151166

152167
In the example above, the two objects - `info1` and `info2` are merged into one using the spread operator.
153168

154-
### Updating object properties
169+
<br />
170+
171+
### 👉 Updating Object Properties
155172

156173
You can also update the properties of an object with the JavaScript spread operator.
157174

@@ -196,6 +213,8 @@ console.log(bookInfo);
196213
*/
197214
```
198215

216+
<br />
217+
199218
## Key Takeaways
200219

201220
- The JavaScript spread operator is denoted by three dots (`...`) and can be used to manipulate arrays and objects.

0 commit comments

Comments
 (0)