This video is about accessing.
I raised goat.
So let me comment out this.
Like that.
And now let's calm down here.
As accessing.
I read.
Okay, so let's declare a variable cost.
Let's say books array is equal to.
Now we are going to take the easiest way that is using the square brackets without using the new.
I mean, the new syntax or the new keyword.
So this is the easy way to go.
So let's say that I want to save MongoDB into this.
After that, Node.js is not period, but instead is comma comma separated.
The next one is I also want to save React JS into it.
So this is my book what?
My book array.
Now if I check my books here we see that I have the red code inside this.
And as before, how can we access array?
Well, we have two ways of accessing arrays.
That is using the.
Index of heart rate.
And that is what I have explained before over here.
So for this one, if we want to access, let's say, this book, you refer by eight index.
So let's come down here, let's say get first book.
First.
Book.
So here you go.
So.
Books and then my square bracket and then zero.
That's my first book.
Okay, so I can assign this one to, let's say cost, let's say book one as B one, book one.
So if I console that log book one, that is my B one.
I have MongoDB here.
So if I want access, second book, third book and the fourth book.
So let's access second book.
So the second book is going to be B two here and now second book will be at index one because the zero
base.
So if I check for book two here.
Like that.
So can you access book three?
Well, you can put this video and then try your luck on that.
So book three, I can copy this one and say this is my book three.
I want access at index two and then book four.
Here are going to be three.
And then here are going to be.
Four.
So here is going to be B to B three and then B four.
So if I search for B.
Two.
I have no jazz.
If I search for B three, I have react.
If I access B four, I have no jazz.
What about if I'm trying to access a data that is inside my array?
What is going to return?
So let's say that I want access for this one before you're going to be with three.
Sorry, guys.
Let's say I want to access index seven here.
Do we have index screen here inside this one node?
So if I console that, log the book for let's see the book four, we see that I get undefined.
So it means that if a record that you are trying to access is not inside, the array is going to retain
undefined.
All right, the next video.
Let's see how we can attract over an array.