1
00:00:00,550 --> 00:00:05,980
This section is all about JavaScript arrays.

2
00:00:06,250 --> 00:00:13,100
This section will contain a lot of coding, challenge any concepts that you learn.

3
00:00:13,120 --> 00:00:16,120
You're going to have a coding challenge about it.

4
00:00:16,850 --> 00:00:22,730
And also the PDF Guide, the script and the final code will be provided.

5
00:00:22,730 --> 00:00:26,090
So make sure we download so that we can follow along.

6
00:00:26,360 --> 00:00:30,740
Well, the next question is what is an array?

7
00:00:31,340 --> 00:00:40,430
Well, arrays are collection of items in a particular order and can be accessed by the index number.

8
00:00:41,030 --> 00:00:49,430
Well, until this point, you know how we are storing or saving data that is using the data types like

9
00:00:49,430 --> 00:00:50,480
variables.

10
00:00:50,480 --> 00:00:56,390
We can store data into variables or string number or boolean.

11
00:00:56,540 --> 00:01:01,970
So arrays is going to take that kind of data storage in the next level.

12
00:01:02,120 --> 00:01:05,209
So as you could see here, this works.

13
00:01:05,209 --> 00:01:08,300
We are going to talk about how to create an array.

14
00:01:08,480 --> 00:01:16,610
It we see that the first option here we can save a couple of items in one single variable.

15
00:01:16,940 --> 00:01:19,670
The same thing applies to the line number three.

16
00:01:19,700 --> 00:01:29,540
Here we are saving this record into one variable, meaning that one variable can contains a lot of data

17
00:01:29,570 --> 00:01:34,460
on unlike the strings and the numbers that are types for arrays.

18
00:01:34,490 --> 00:01:38,510
We can save multiple collection of record.

19
00:01:38,780 --> 00:01:44,210
So let's do a few more to use this diagram to explain what is array.

20
00:01:44,570 --> 00:01:53,420
One good thing we need to bear in mind is that arrays are index based, meaning that the index determine

21
00:01:53,420 --> 00:01:58,280
where this particular record or data is located.

22
00:01:58,460 --> 00:02:05,150
So we have index zero one and two, meaning when we say arrays are index based, meaning that they start

23
00:02:05,150 --> 00:02:06,020
from zero.

24
00:02:06,200 --> 00:02:12,980
So if we want to count, if we want to get the first record that won't reference as index zero, we

25
00:02:12,980 --> 00:02:18,140
would w more to create an access search record for the mean time.

26
00:02:18,170 --> 00:02:19,730
Let's explore more.

27
00:02:20,030 --> 00:02:20,600
All right.

28
00:02:20,600 --> 00:02:28,100
So let's say that for our purpose, we are going to create a race of books, meaning that we have a

29
00:02:28,100 --> 00:02:30,170
list of books that we want to save.

30
00:02:30,750 --> 00:02:32,290
Okay, let's say we have five books.

31
00:02:32,300 --> 00:02:33,550
Let's say we have one book.

32
00:02:33,560 --> 00:02:38,060
For example, we're thinking that, well, then that one's pretty easy.

33
00:02:38,060 --> 00:02:41,270
I can just declare a variable, say const.

34
00:02:42,090 --> 00:02:42,810
Let's say.

35
00:02:44,760 --> 00:02:50,010
And then is equal to, let's say the book name is called Kiss.

36
00:02:50,640 --> 00:02:51,420
Then I'm done.

37
00:02:51,420 --> 00:02:52,930
So why do I need a red?

38
00:02:53,400 --> 00:02:54,900
Okay for one book?

39
00:02:55,110 --> 00:02:56,040
It's okay.

40
00:02:56,070 --> 00:02:56,640
Whatever.

41
00:02:56,640 --> 00:02:57,990
If you have two books.

42
00:02:58,350 --> 00:02:59,590
All right, let's see now.

43
00:02:59,610 --> 00:03:00,010
Okay.

44
00:03:00,030 --> 00:03:01,210
It's also easy.

45
00:03:01,230 --> 00:03:03,990
I can also declare a variable called cost.

46
00:03:04,260 --> 00:03:10,410
And I will say book two is equal to Node.js.

47
00:03:11,980 --> 00:03:12,400
Yeah.

48
00:03:12,460 --> 00:03:13,610
It's also easy, right?

49
00:03:13,680 --> 00:03:14,830
Okay, that's perfect.

50
00:03:14,860 --> 00:03:20,020
What about if we have 100 books?

51
00:03:20,290 --> 00:03:22,450
Are you going to create a variable for book one?

52
00:03:22,450 --> 00:03:24,380
Book two, book three and like that?

53
00:03:24,400 --> 00:03:24,990
No.

54
00:03:25,000 --> 00:03:27,910
That is why a race comes into play.

55
00:03:29,170 --> 00:03:29,440
Okay.

56
00:03:29,440 --> 00:03:37,600
So let's take it that in one case we are going to create an array of books and we have taken this shelf

57
00:03:37,600 --> 00:03:39,820
that's going to hold our book.

58
00:03:39,840 --> 00:03:47,710
So this one is an array, array box, contain lines in the hallway and now it's ready to have some books

59
00:03:47,710 --> 00:03:51,400
in it and can see that we have individual shelves here.

60
00:03:51,400 --> 00:03:54,340
So these are the indexes in my array.

61
00:03:54,490 --> 00:04:02,740
So let's see that for the first sheriff, I have book one and it's going to donate zero index to it,

62
00:04:03,070 --> 00:04:10,900
meaning that if I want to retrieve this book, I need to reference zero in the zero, meaning it represents

63
00:04:10,900 --> 00:04:11,470
this book.

64
00:04:11,470 --> 00:04:15,760
Then I can take some book out if I reference index zero.

65
00:04:16,209 --> 00:04:18,670
What about if I want to put another book here?

66
00:04:18,670 --> 00:04:22,420
Then the same thing is going to give me as index one.

67
00:04:22,450 --> 00:04:25,750
The next book as that index too.

68
00:04:25,750 --> 00:04:29,410
And the last book here, give me as index three.

69
00:04:29,650 --> 00:04:40,690
So these indexes you see here is being created for us automatically as soon as we create an array instance.

70
00:04:40,690 --> 00:04:43,030
Here, let me show you here what we have here.

71
00:04:43,030 --> 00:04:43,780
Yes.

72
00:04:43,990 --> 00:04:49,870
As soon as you make this square bracket here, it means that we are creating an array or using this

73
00:04:49,870 --> 00:04:50,590
syntax.

74
00:04:50,980 --> 00:04:51,250
Good.

75
00:04:51,310 --> 00:04:57,730
So in this video, let's see how we can create array from scratch using code.

