Merge pull request #277 from usernamehw/patch-19

Update article.md
This commit is contained in:
Ilya Kantor 2017-11-01 09:00:41 +03:00 committed by GitHub
commit ef18a97d73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
# Rest parameters and spread operator
Many JavaScript built-in functions support on arbitrary number of arguments.
Many JavaScript built-in functions support an arbitrary number of arguments.
For instance:
@ -207,7 +207,7 @@ alert( [...str] ); // H,e,l,l,o
The spread operator internally uses iterators to gather elements, the same way as `for..of` does.
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]`.
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]`.
For this particular task we could also use `Array.from`, because it converts an iterable (like a string) into an array: