This section is all about JavaScript arrays.
This section will contain a lot of coding, challenge any concepts that you learn.
You're going to have a coding challenge about it.
And also the PDF Guide, the script and the final code will be provided.
So make sure we download so that we can follow along.
Well, the next question is what is an array?
Well, arrays are collection of items in a particular order and can be accessed by the index number.
Well, until this point, you know how we are storing or saving data that is using the data types like
variables.
We can store data into variables or string number or boolean.
So arrays is going to take that kind of data storage in the next level.
So as you could see here, this works.
We are going to talk about how to create an array.
It we see that the first option here we can save a couple of items in one single variable.
The same thing applies to the line number three.
Here we are saving this record into one variable, meaning that one variable can contains a lot of data
on unlike the strings and the numbers that are types for arrays.
We can save multiple collection of record.
So let's do a few more to use this diagram to explain what is array.
One good thing we need to bear in mind is that arrays are index based, meaning that the index determine
where this particular record or data is located.
So we have index zero one and two, meaning when we say arrays are index based, meaning that they start
from zero.
So if we want to count, if we want to get the first record that won't reference as index zero, we
would w more to create an access search record for the mean time.
Let's explore more.
All right.
So let's say that for our purpose, we are going to create a race of books, meaning that we have a
list of books that we want to save.
Okay, let's say we have five books.
Let's say we have one book.
For example, we're thinking that, well, then that one's pretty easy.
I can just declare a variable, say const.
Let's say.
And then is equal to, let's say the book name is called Kiss.
Then I'm done.
So why do I need a red?
Okay for one book?
It's okay.
Whatever.
If you have two books.
All right, let's see now.
Okay.
It's also easy.
I can also declare a variable called cost.
And I will say book two is equal to Node.js.
Yeah.
It's also easy, right?
Okay, that's perfect.
What about if we have 100 books?
Are you going to create a variable for book one?
Book two, book three and like that?
No.
That is why a race comes into play.
Okay.
So let's take it that in one case we are going to create an array of books and we have taken this shelf
that's going to hold our book.
So this one is an array, array box, contain lines in the hallway and now it's ready to have some books
in it and can see that we have individual shelves here.
So these are the indexes in my array.
So let's see that for the first sheriff, I have book one and it's going to donate zero index to it,
meaning that if I want to retrieve this book, I need to reference zero in the zero, meaning it represents
this book.
Then I can take some book out if I reference index zero.
What about if I want to put another book here?
Then the same thing is going to give me as index one.
The next book as that index too.
And the last book here, give me as index three.
So these indexes you see here is being created for us automatically as soon as we create an array instance.
Here, let me show you here what we have here.
Yes.
As soon as you make this square bracket here, it means that we are creating an array or using this
syntax.
Good.
So in this video, let's see how we can create array from scratch using code.