Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update iterable/article.md #3740

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 1-js/05-data-types/06-iterable/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Of course, the `for..of` loop over such an iterable would be endless. But we can

## String is iterable

Arrays and strings are most widely used built-in iterables.
Arrays and strings are the most widely used built-in iterables.

For a string, `for..of` loops over its characters:

Expand Down Expand Up @@ -168,11 +168,11 @@ That is rarely needed, but gives us more control over the process than `for..of`
Two official terms look similar, but are very different. Please make sure you understand them well to avoid the confusion.

- *Iterables* are objects that implement the `Symbol.iterator` method, as described above.
- *Array-likes* are objects that have indexes and `length`, so they look like arrays.
- *Array-likes* are objects that have indexes and `length`, so they look like arrays. They can use the [`concat` method](/array-methods#concat) by setting the `Symbol.isConcatSpreadable` property.

When we use JavaScript for practical tasks in a browser or any other environment, we may meet objects that are iterables or array-likes, or both.

For instance, strings are both iterable (`for..of` works on them) and array-like (they have numeric indexes and `length`).
For instance, strings are both iterable (`for..of` works on them, and use the `Symbol.iterable` method) and array-like (they have numeric indexes and `length`, and use the `Symbol.isConcatSpreadable` property).

But an iterable may not be array-like. And vice versa an array-like may not be iterable.

Expand Down