Skip to content

Commit ef18a97

Browse files
authored
Merge pull request javascript-tutorial#277 from usernamehw/patch-19
Update article.md
2 parents a61add9 + d04b6ac commit ef18a97

File tree

1 file changed

+3
-3
lines changed
  • 1-js/06-advanced-functions/02-rest-parameters-spread-operator

1 file changed

+3
-3
lines changed

1-js/06-advanced-functions/02-rest-parameters-spread-operator/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Rest parameters and spread operator
22

3-
Many JavaScript built-in functions support on arbitrary number of arguments.
3+
Many JavaScript built-in functions support an arbitrary number of arguments.
44

55
For instance:
66

@@ -35,7 +35,7 @@ For instance, to gather all arguments into array `args`:
3535
function sumAll(...args) { // args is the name for the array
3636
let sum = 0;
3737

38-
for(let arg of args) sum += arg;
38+
for (let arg of args) sum += arg;
3939

4040
return sum;
4141
}
@@ -207,7 +207,7 @@ alert( [...str] ); // H,e,l,l,o
207207
208208
The spread operator internally uses iterators to gather elements, the same way as `for..of` does.
209209
210-
So, for a string, `for..of` returns characters and `...str` becomes `"h","e","l","l","o"`. The list of characters is passed to array initializer `[...str]`.
210+
So, for a string, `for..of` returns characters and `...str` becomes `"H","e","l","l","o"`. The list of characters is passed to array initializer `[...str]`.
211211
212212
For this particular task we could also use `Array.from`, because it converts an iterable (like a string) into an array:
213213

0 commit comments

Comments
 (0)