1
00:00:02,320 --> 00:00:07,620
So what's an iterable in Javascript? An iterable can be defined

2
00:00:07,630 --> 00:00:14,760
technically, there it's basically an object or any objects that implement the iterable protocol and have

3
00:00:14,760 --> 00:00:20,320
to is @@iterator method with the symbol iterator property.

4
00:00:20,320 --> 00:00:25,810
Now symbols are a special type of values in Javascript, we'll dive into them way later since they're really

5
00:00:25,810 --> 00:00:33,340
niche and specific and therefore the human readable definition of an iterable in the end is that we can use a for/of

6
00:00:33,460 --> 00:00:34,510
loop on it.

7
00:00:34,600 --> 00:00:36,600
Yes, it's indeed as simple as that,

8
00:00:36,700 --> 00:00:38,380
we can loop through it with for/of.

9
00:00:39,180 --> 00:00:42,870
Now the important thing is that not every iterable in Javascript is an array.

10
00:00:42,880 --> 00:00:49,750
We work with arrays thus far but there also are other iterable objects, like a node list for example

11
00:00:49,750 --> 00:00:51,740
which we saw in the last course module

12
00:00:51,820 --> 00:00:56,950
but also strings and also maps and sets which we'll have a look at later.

13
00:00:56,950 --> 00:01:01,930
Now there also is another term which I already used and that's array-like and that's actually not the

14
00:01:01,930 --> 00:01:03,380
same as an iterable,

15
00:01:03,430 --> 00:01:09,470
both iterable and array-like are official terms in the Javascript language.

16
00:01:09,490 --> 00:01:12,380
Now what are array-like objects therefore?

17
00:01:12,550 --> 00:01:19,930
Again, the technical definition is here, much more readable, that an array-like object are in the end any

18
00:01:19,930 --> 00:01:25,120
objects that have a length property and use indexes to access items,

19
00:01:25,120 --> 00:01:26,510
it's as simple as that

20
00:01:26,650 --> 00:01:32,680
and I'd say it is also pretty clear to us humans. Now just as with iterables, not every array-like object

21
00:01:32,680 --> 00:01:33,280
is an array,

22
00:01:33,340 --> 00:01:39,730
that's why it's called array-like. We have array-like objects, like node list and string. Node lists and

23
00:01:39,730 --> 00:01:45,800
strings are objects that have a length, that have indexes and where we can use for/of and still, they're

24
00:01:45,840 --> 00:01:51,820
not real arrays because as you will learn in this module, real arrays have a couple of interesting behaviors

25
00:01:52,120 --> 00:01:59,530
and also a bunch of important methods available to them which do not exist on these array-like or

26
00:01:59,530 --> 00:02:01,360
iterable objects.

27
00:02:01,360 --> 00:02:06,910
Now with these definitions out of the way, let's dive a bit deeper into arrays before we then also have

28
00:02:06,910 --> 00:02:09,460
a look at other array-like objects and iterables.
