Let's get started with how we can create an array.
I have already created a folder core areas and inside I have two files, my HTML and then my JavaScript
file.
So inside my HTML, I have a few lines of code with the edge two and here I have link app my JavaScript
file.
So now let's work inside the JavaScript file.
So how can we create an array?
We have two ways of creating an array.
So the first method is called the using the new keyword.
So the first method is called using the new key.
Word.
Is that so?
Here you go.
So context.
And then the name of my array, I would name it as my array is equal to new and then my array so new
and then array as that.
So inside this I can put in any data I want to save.
For the meantime, let's say that we are creating books array as we showed in the diagram.
So my books are array.
So inside here I can put a new book that I want.
So here let's say that I want to save this book.
The next one html book.
The third one is going to be as no jazz book.
Yes.
So any time I reference books, I have this record.
So let's check inside our console and then let's search for books.
You see that?
I have the books, Harry.
Perfect.
So another way how we can add record to the books is like this one.
So let me comment out this.
Let me copy this one.
Let me comment out the first one.
And now after this one, we have created a new array, an empty array with this in time.
So this one will give me an empty array as that.
So if I check inside my console, it could see that I have the square bracket, which is an array,
meaning there is nothing inside.
So let's see how we can add books into this empty array.
So first of all, I want to add a book or the index zero.
So I need to specify books and then my square bracket and then index zero.
I want to save, let's say CSS into that.
So, so behind the scene are the index zero.
I have saved CSS book.
So if I check my console for books.
Let's see.
You can see that I have CSIS in the first array.
So the next is if I want to put the next record as books.
And then square bracket.
I want to put an index one, which is my HTML.
So the same thing, if I sell four books, you can see that I have a HTML at index one.
So I can go on and go on and go on and add as many books as I want.
So here, index two.
Then let me save Node.js also.
Perfect.
So let me check now I have that.
That's the first method.
So first we create and then we assign it record into it.
Or we can quickly add the variables inside.
Let me call this one as books.
Two here, books, two books, two to write a name will not be conflict.
So here one method.
Whether you go by this way or declare the empty array and then add the record or declare the array.
And on this part you can add in your record.
That's the first method of creating an array.
The second method for creating an array is using the array literal.
So step number two or method two is using the array literal.
And it goes like this the same thing.
Let me name this one as books.
Three so that they won't be conflict and all.
What I need here is to bring my square bracket.
And that is it.
So if I search for.
Books.
Three.
We see that same as before.
I have an empty array.
So the same way I can add my record here as let me call this one as JavaScript.
React.
Express DJs and let's say redox.
Yes.
So if I search for books here with three, I have those records.
So the same way I can also add the record in this way as before.
So I can copy this one and then pass it here and comment on this one.
So as before, let me remove here I can create an empty array and then here at record.
Okay.
So inside here I would take books and then the index zero.
I want to save JavaScript file JavaScript book JS empty string here, JavaScript here and then books
three at index zero.
Index one.
I want to save also my React book and books three at index.
Index two I want to save.
Let's say what book express js.
Into that.
So if I check for book three as before, I have it.
Perfect.
So let's have some facts about array.
For array, we can save any kind of record.
I mean, any kind of data type we can save into array.
So here array can take any data.
Type variable value.
So comes let's see my array is equal to I can save string of say as before Let's say what string let's
see food into that Yes, food is a string and then I can save boolean as let's say true into that.
I can also save a number, say 20 into that I can also save null into that I can also save undefined
into that consider how flexible this this array is.
With one variable we can save multiple data types into it.
That is awesome.
But guys take note here.
They add the name of array.
Much depends what you are saving into it.
So let's say that this array is about books and you are saving food.
True 20 now and undefined weight.
Where if I take this area, I'll ask myself what is this array?
Or about the take away here is that array can store any data type.
Perfect.
All right, so that is it about the arrays.
The next video.
Let's see how we can access these arrays.
Meaning after creating, how can I access these array?
For example, if I actually place I don't want all this record give me only let's say react books or
I mean JavaScript books or Node.js book, how are we going to do it?
And that's what you call accessing arrays.
Let's get into that in the next video.