1
00:00:02,530 --> 00:00:11,710
Let's get started with a ray meters and ray meters are the meters that we can use to operate on the

2
00:00:11,710 --> 00:00:12,500
arrays.

3
00:00:12,520 --> 00:00:17,620
For example, let's say I want to remove a record from an array.

4
00:00:17,650 --> 00:00:22,810
I need a ray method if I want to add record to an array.

5
00:00:22,840 --> 00:00:25,030
I need a remitted.

6
00:00:25,210 --> 00:00:31,000
If I want to know how many records are in the array, I need a ray method.

7
00:00:31,270 --> 00:00:35,290
That is what we are going to talk about in this particular video.

8
00:00:35,320 --> 00:00:40,840
We have couple of them, so let's take them one by one or one after the other.

9
00:00:41,020 --> 00:00:47,770
So let me comment out this one and let's use the same data here as our array here.

10
00:00:47,920 --> 00:00:49,810
So let me comment out this one.

11
00:00:49,810 --> 00:00:54,190
And now we are making use of this array to do some manipulations.

12
00:00:54,190 --> 00:00:56,560
So here let's comment.

13
00:00:56,860 --> 00:00:58,570
I think let me remove this one.

14
00:01:00,010 --> 00:01:03,110
Even cases to have some one half one code here.

15
00:01:03,190 --> 00:01:03,370
Okay.

16
00:01:03,380 --> 00:01:04,060
It is good.

17
00:01:04,510 --> 00:01:06,850
So I methods.

18
00:01:09,760 --> 00:01:12,180
Array matters.

19
00:01:12,700 --> 00:01:16,090
We have couple of them, so let's get started with that.

20
00:01:17,280 --> 00:01:20,460
All the description we provided in the PDF Guide.

21
00:01:20,460 --> 00:01:21,450
So don't worry.

22
00:01:21,900 --> 00:01:26,280
Just follow along and understand the concept that is most important thing.

23
00:01:26,550 --> 00:01:32,550
So the first array that we will talk about that we will talk about is what you call push.

24
00:01:33,580 --> 00:01:34,150
Okay.

25
00:01:34,150 --> 00:01:39,910
So push us element at the end of an array.

26
00:01:40,060 --> 00:01:44,650
So it is used to add elements at the end of an array.

27
00:01:44,950 --> 00:01:51,550
So let's say that for this book in future I want to add new book, how am I going to do it?

28
00:01:51,670 --> 00:01:56,470
Maybe thinking, well, I can come here, have some, come on, then I can add it here.

29
00:01:56,680 --> 00:02:01,420
But this is not dynamic, meaning I'm doing it manually.

30
00:02:01,660 --> 00:02:04,870
So for programming it should be dynamic, right?

31
00:02:04,870 --> 00:02:06,190
Your code should be dynamic.

32
00:02:06,190 --> 00:02:07,000
Not like one.

33
00:02:07,000 --> 00:02:08,289
One way of doing things.

34
00:02:09,449 --> 00:02:12,630
So let me remove that and let's make everything dynamic.

35
00:02:12,630 --> 00:02:15,930
So how can we add record to an array?

36
00:02:15,960 --> 00:02:27,690
Using push is as simple as A-B-C or what I need is I will bring in mine arrays, that is books on that.

37
00:02:27,690 --> 00:02:35,130
If I press dot, I have all these methods that are be taking it through, at least most of them.

38
00:02:35,340 --> 00:02:37,850
So here the first one is called push.

39
00:02:37,860 --> 00:02:39,990
Then I want to push what record?

40
00:02:39,990 --> 00:02:40,800
What data?

41
00:02:40,830 --> 00:02:43,740
Let's say I want to push in HTML.

42
00:02:43,740 --> 00:02:46,050
Sorry, I have let's say CSS into it.

43
00:02:46,560 --> 00:02:48,930
So now if I check my console.

44
00:02:50,360 --> 00:02:50,990
Here.

45
00:02:51,020 --> 00:03:01,580
Then I search for books to see that I have the this record you see that I have CCIS at the end of the

46
00:03:01,600 --> 00:03:02,240
array.

47
00:03:02,270 --> 00:03:04,910
That is how it works through.

48
00:03:04,910 --> 00:03:09,920
The push is used to add record at the end of the array.

49
00:03:10,190 --> 00:03:13,490
So what are some of the use cases here able to push?

50
00:03:13,730 --> 00:03:21,350
Well, if you get back to back end development, they are a lot of use cases even on the front end.

51
00:03:21,440 --> 00:03:28,700
Let's say that you want to know how many records are in this book array.

52
00:03:28,790 --> 00:03:35,270
If at least there are ten records in this array, maybe you can say, can I only add one more book into

53
00:03:35,270 --> 00:03:35,420
it?

54
00:03:35,420 --> 00:03:42,500
So first we can make condition and say that, well, if the length or the record in this book is less

55
00:03:42,500 --> 00:03:47,180
than ten, then I can add a book to repeat because it's not full yet.

56
00:03:47,450 --> 00:03:48,050
Okay.

57
00:03:48,080 --> 00:03:52,610
It's not full meaning it's not up to my requirements so I can go back this way.

58
00:03:53,120 --> 00:04:01,880
And another scenario is that where I push a lot is that let's say, I mean, you are doing a block application

59
00:04:02,120 --> 00:04:08,750
and then you are doing what is called follow and unfollow user where we see that in some use cases,

60
00:04:08,750 --> 00:04:15,620
if a user is not following a certain user, we can push the user into an array of followers of that

61
00:04:15,620 --> 00:04:16,130
follower.

62
00:04:16,430 --> 00:04:22,580
So that is I mean, a high level is now here, but push is used a lot, so we pay attention to that.

63
00:04:22,670 --> 00:04:27,740
The next method is what you call pop.

64
00:04:29,870 --> 00:04:36,500
As the name implies, Pop is used to move an element at the end of the array.

65
00:04:36,800 --> 00:04:39,720
So for the pop, it doesn't take anything.

66
00:04:39,740 --> 00:04:41,440
I'll just take in the box.

67
00:04:41,460 --> 00:04:44,030
Then I will say, Pop, let's pop.

68
00:04:44,030 --> 00:04:44,510
Champagne.

69
00:04:44,570 --> 00:04:48,860
See how your popping champagne is, puff when you pop it out.

70
00:04:48,920 --> 00:04:49,480
Right.

71
00:04:49,490 --> 00:04:54,470
So if I sip this one now, I want to check the records in the boost array.

72
00:04:55,120 --> 00:05:02,560
What would be the answer if Pop remove a record at the end of the era and is the last record here?

73
00:05:03,120 --> 00:05:07,840
Okay, so if I save it and I check for boost, this success will be removed.

74
00:05:08,320 --> 00:05:09,130
Check it out.

75
00:05:10,180 --> 00:05:15,840
You see, we don't have Ccaea, but if I did not push pop out this one, I save it.

76
00:05:15,850 --> 00:05:20,950
If I check it, we see that I'm going to have the CSS which is here.

77
00:05:21,190 --> 00:05:21,490
Good.

78
00:05:21,490 --> 00:05:23,440
That is the pop for you.

79
00:05:24,550 --> 00:05:29,620
The next method is what we call the on shift.

80
00:05:29,650 --> 00:05:34,480
This name for me is all that descriptive or is the on shift?

81
00:05:34,570 --> 00:05:35,200
But let's see.

82
00:05:35,200 --> 00:05:41,650
The meaning on shift simply means that it is used to add record at the beginning of an array.

83
00:05:42,110 --> 00:05:42,330
Is it?

84
00:05:42,340 --> 00:05:42,960
I see.

85
00:05:42,970 --> 00:05:44,310
I mean, on shift.

86
00:05:44,320 --> 00:05:46,240
You are shifting something, right?

87
00:05:46,240 --> 00:05:48,170
But on shift, I don't know.

88
00:05:48,190 --> 00:05:49,330
Well, that is it.

89
00:05:49,330 --> 00:05:50,570
So we have no option.

90
00:05:50,590 --> 00:05:54,640
So the next one is what you call the on shift.

91
00:05:56,380 --> 00:05:58,580
Aren't the works here.

92
00:05:58,990 --> 00:06:00,220
Throughout confusion.

93
00:06:00,220 --> 00:06:00,820
Come here.

94
00:06:01,180 --> 00:06:07,650
So let's say that I want to add a record at the beginning of this recording here.

95
00:06:08,110 --> 00:06:16,030
You see, the difference is the push is used to add at the end and then on shift add at the beginning

96
00:06:16,030 --> 00:06:17,050
of an array.

97
00:06:17,080 --> 00:06:18,930
So here we go.

98
00:06:18,940 --> 00:06:24,520
So books dot on shift and now I want to shift.

99
00:06:24,520 --> 00:06:25,150
What book?

100
00:06:25,150 --> 00:06:26,410
Let me say no.

101
00:06:27,480 --> 00:06:29,940
See if I check this one.

102
00:06:30,060 --> 00:06:30,480
You see that?

103
00:06:30,480 --> 00:06:34,470
I have no idea at the beginning of the array.

104
00:06:34,500 --> 00:06:36,870
That is the on shift for you.

105
00:06:37,410 --> 00:06:40,770
You're going to have I mean, a lot of challenges here.

106
00:06:40,770 --> 00:06:43,560
I mean, a lot of coding challenge, no challenges here.

107
00:06:43,590 --> 00:06:45,270
Everybody should pay attention.

108
00:06:45,540 --> 00:06:49,470
The next one is called the shift, right?

109
00:06:49,470 --> 00:06:51,930
So here the next one going to be shift.

110
00:06:51,930 --> 00:06:57,720
So a shift is used to remove an element from the beginning of an array.

111
00:06:58,140 --> 00:07:01,260
So you can see that some differences here.

112
00:07:01,290 --> 00:07:02,310
Let me show you here.

113
00:07:02,760 --> 00:07:08,130
Push is used to push record at the end.

114
00:07:08,780 --> 00:07:10,220
And on shared.

115
00:07:11,020 --> 00:07:14,980
It's used to our records at the beginning.

116
00:07:15,250 --> 00:07:24,610
And Pop is used to remove record from from the end and then shift remove record from the beginning.

117
00:07:24,730 --> 00:07:26,860
You see how the differences are right now.

118
00:07:27,370 --> 00:07:29,700
So let's say I want to remove MongoDB.

119
00:07:29,710 --> 00:07:31,570
So let me comment out this one.

120
00:07:32,050 --> 00:07:33,100
The on shift.

121
00:07:34,050 --> 00:07:39,060
Let me comment out the push also done with that to the shift.

122
00:07:39,630 --> 00:07:41,570
So I would take the books away.

123
00:07:41,580 --> 00:07:42,930
Then I would say shift.

124
00:07:42,930 --> 00:07:45,030
The shift doesn't take anything.

125
00:07:45,150 --> 00:07:52,560
So if I save it and I'll check my console, you see that I don't have MongoDB because shift has removed

126
00:07:52,590 --> 00:07:55,650
MongoDB at the beginning of the array.

127
00:07:56,490 --> 00:08:09,210
The next array method is what we call the index of so index of remember when when we're treating strings,

128
00:08:09,210 --> 00:08:16,500
we talk about index of and I say that you will come back because index of operate on arrays, remember.

129
00:08:16,500 --> 00:08:23,010
So if you have a string of characters, we can split it and then use index of determine where a particular

130
00:08:23,010 --> 00:08:24,180
string or case.

131
00:08:24,390 --> 00:08:35,400
So index off retains the index of the first element in an array that matches the specified value.

132
00:08:35,460 --> 00:08:43,530
So we index of the kind of searching record in an array if it exists where it return true.

133
00:08:43,770 --> 00:08:45,360
So here index.

134
00:08:45,360 --> 00:08:51,060
Let's say that I want to search for a record at index one.

135
00:08:51,390 --> 00:08:53,010
Do you have a record of that?

136
00:08:53,280 --> 00:08:54,000
Let's see.

137
00:08:54,180 --> 00:09:03,720
So I would declare variable counts and say result is equal to books dot index of.

138
00:09:03,960 --> 00:09:08,610
Then I want to check for let's say in HTML.

139
00:09:08,610 --> 00:09:12,110
So let's check at which index that HTML.

140
00:09:12,120 --> 00:09:14,430
Okay, you see it?

141
00:09:14,430 --> 00:09:15,150
Okay.

142
00:09:15,180 --> 00:09:23,610
At index three, that is zero one, two, this is two and three because this is combined together.

143
00:09:23,610 --> 00:09:25,110
Okay, let's make it like this one.

144
00:09:25,110 --> 00:09:25,650
Yeah.

145
00:09:25,650 --> 00:09:27,840
So zero one, two, three.

146
00:09:27,840 --> 00:09:30,810
That's why we have the index three.

147
00:09:30,810 --> 00:09:36,420
So if you get a positive number, it means that it exists.

148
00:09:36,840 --> 00:09:43,620
But if you get a negative number, it means that what we are trying to search for doesn't exist.

149
00:09:43,620 --> 00:09:47,850
So let's say I want to search for PHP.

150
00:09:48,870 --> 00:09:55,440
So if I check for this one, there is no PHP value in my record, so I get what?

151
00:09:55,440 --> 00:09:56,580
Negative one?

152
00:09:57,120 --> 00:10:00,030
So negative one simply means that it doesn't exist.

153
00:10:00,030 --> 00:10:03,180
So let's search for MongoDB.

154
00:10:04,800 --> 00:10:07,760
Analysis said for that in the zero.

155
00:10:07,770 --> 00:10:17,550
So let's say our brain in uppercase here let's say for that again so the clue here is that index of

156
00:10:17,550 --> 00:10:25,980
is also case sensitive meaning that if here is lowercase by the beginning we are searching for uppercase

157
00:10:26,130 --> 00:10:27,840
going to say please, I don't know you.

158
00:10:28,410 --> 00:10:35,550
So to avoid this one, you need to I mean, transform the text, all of them to lowercase or to uppercase

159
00:10:35,550 --> 00:10:37,890
so we can take this array here.

160
00:10:37,920 --> 00:10:38,640
Okay.

161
00:10:38,640 --> 00:10:42,630
And then use map to create a new instance of this array.

162
00:10:42,630 --> 00:10:47,310
And then we are going to transform all the text in the array.

163
00:10:47,340 --> 00:10:55,080
Then whatever about passing here, I can use the to lowercase transform so to match whatever I have

164
00:10:55,080 --> 00:10:55,860
my record.

165
00:10:55,980 --> 00:10:59,580
That's one scenario here and that is the index of for you.

166
00:11:00,150 --> 00:11:08,250
The next one is going to be the last index of the last index of returns, the index of the last element

167
00:11:08,250 --> 00:11:12,000
in an array that matches the specified value.

168
00:11:12,660 --> 00:11:13,620
So let's see.

169
00:11:13,830 --> 00:11:20,310
So here, let me bring out because my comment is getting longer here.

170
00:11:20,310 --> 00:11:23,460
So let me bring the record here and let's continue the method.

171
00:11:24,000 --> 00:11:28,560
The next one is going to be as last.

172
00:11:30,370 --> 00:11:31,330
Index.

173
00:11:32,810 --> 00:11:34,820
Of make it so.

174
00:11:36,510 --> 00:11:40,610
Let's assign or I can quickly console.log like that.

175
00:11:40,620 --> 00:11:41,940
I would take the books.

176
00:11:43,520 --> 00:11:46,460
And then at last index of.

177
00:11:47,460 --> 00:11:50,220
And then our search for, let's say, a HTML.

178
00:11:51,700 --> 00:11:53,500
No, I get three.

179
00:11:54,010 --> 00:11:59,900
So you see that it catch at where I mean index 30123.

180
00:12:00,040 --> 00:12:04,210
If I search for node JS.

181
00:12:05,320 --> 00:12:07,780
It worked at index one.

182
00:12:07,930 --> 00:12:15,430
So it retains the last element in an array that matches the specified value.

183
00:12:15,550 --> 00:12:18,520
So what about include a key?

184
00:12:18,940 --> 00:12:22,120
The next method is going to be the include method.

185
00:12:22,450 --> 00:12:30,100
So this method, you are going to use all of these methods and least normally I normally use push most

186
00:12:30,100 --> 00:12:38,050
often and then include an index of lost index of where it depends on some use cases.

187
00:12:38,080 --> 00:12:38,650
Okay.

188
00:12:38,740 --> 00:12:46,480
So what are the include says include returns a boolean indicating whether an array includes a certain

189
00:12:46,480 --> 00:12:50,230
value the same as using or the index of.

190
00:12:50,470 --> 00:12:59,530
So the include here which by when to return a true or false, but for an index of it returns a value

191
00:12:59,530 --> 00:13:03,390
if it exists a negative value if it doesn't exist.

192
00:13:03,400 --> 00:13:06,190
So here is index or include.

193
00:13:06,190 --> 00:13:08,150
So I'll bring here as include.

194
00:13:08,170 --> 00:13:09,270
Now let's see.

195
00:13:09,280 --> 00:13:10,360
Is it that I get true?

196
00:13:10,360 --> 00:13:14,890
Because here there is no JS inside the so you have true.

197
00:13:15,160 --> 00:13:22,630
If I search for let's say no just says such that I get false meaning that this value doesn't exist.

198
00:13:22,630 --> 00:13:31,600
So using this I mean include here and then the index of this one is more descriptive by where?

199
00:13:31,600 --> 00:13:33,250
It depends on some use cases.

200
00:13:33,400 --> 00:13:33,970
Good.

201
00:13:34,510 --> 00:13:40,870
And then the next step is going to the next array is going to be okay, let me bring this one here and

202
00:13:40,870 --> 00:13:41,770
this one here.

203
00:13:41,950 --> 00:13:45,370
So maybe in future you can reference that.

204
00:13:45,490 --> 00:13:48,520
So the last index for this one, I'm just console.log.

205
00:13:48,520 --> 00:13:50,920
The answer on the fly.

206
00:13:50,980 --> 00:13:51,200
Okay.

207
00:13:51,220 --> 00:13:52,990
That's why I put them into console.log.

208
00:13:52,990 --> 00:13:56,740
So this one is same as if you're confused about this one.

209
00:13:57,220 --> 00:14:04,630
I can assign the result, let's say cause as my results that then I can console.log this one by this

210
00:14:04,630 --> 00:14:07,000
one I just want to console.log it on the fly.

211
00:14:07,030 --> 00:14:08,860
That's why I put it inside my console.

212
00:14:08,860 --> 00:14:09,640
Look like that.

213
00:14:09,910 --> 00:14:16,840
Okay, so now let me I'm done with the include the next one going to be the reverse.

214
00:14:16,840 --> 00:14:20,290
Remember, reverse is used to reverse the array.

215
00:14:20,290 --> 00:14:23,230
You may need this one to be able to challenge.

216
00:14:23,230 --> 00:14:25,420
I may solve the upcoming coding challenge.

217
00:14:25,660 --> 00:14:26,890
So let's see.

218
00:14:26,890 --> 00:14:28,900
Let me comment out this one.

219
00:14:29,110 --> 00:14:30,780
Copy it and put it here.

220
00:14:30,800 --> 00:14:33,490
Now let me change this one to reverse.

221
00:14:33,490 --> 00:14:34,030
Reverse.

222
00:14:34,030 --> 00:14:37,570
That doesn't take in anything like that.

223
00:14:38,200 --> 00:14:42,280
So if I save it, let's see the reverse value here.

224
00:14:42,760 --> 00:14:48,520
Now a HTML has become first followed by React and MongoDB is last.

225
00:14:48,550 --> 00:14:49,060
We see that.

226
00:14:49,060 --> 00:14:57,250
Now HTML here has become one here first and then react followed by and then MongoDB is the last one.

227
00:14:57,250 --> 00:15:01,000
So it is used to reverse array.

228
00:15:01,600 --> 00:15:06,710
The next method is going to be reduce pro.

229
00:15:06,970 --> 00:15:11,200
This is the crucial method that we're going to use it a lot.

230
00:15:11,200 --> 00:15:11,740
A lot.

231
00:15:11,740 --> 00:15:12,220
A lot.

232
00:15:12,220 --> 00:15:12,700
A lot.

233
00:15:12,700 --> 00:15:13,120
A lot.

234
00:15:13,120 --> 00:15:13,690
A lot.

235
00:15:13,870 --> 00:15:16,750
So what is the reduce.

236
00:15:17,480 --> 00:15:18,310
Made it.

237
00:15:18,590 --> 00:15:19,220
Okay.

238
00:15:19,250 --> 00:15:25,290
So we have a specific section to talk about how we can loop through a race.

239
00:15:25,310 --> 00:15:32,780
But for the meantime, let's start with the reduce because we may need that one to solve the upcoming

240
00:15:32,780 --> 00:15:33,770
coding challenge.

241
00:15:33,770 --> 00:15:40,490
So I think let's postpone that because risk pressure method and take my time to explain to you.

242
00:15:40,640 --> 00:15:43,070
So let's continue in the next video, guys.

