JavaScript Array Methods | JavaScript Tutorial in Hindi #17
Aug 15, 2023
JavaScript Array Methods | JavaScript Tutorial in Hindi #17
Let’s look at some array methods in JavaScript Link to the Repl - https://replit.com/@codewithharry/17A … Join Replit - https://join.replit.com/CodeWithHarry Download Notes - https://drive.google.com/drive/folder … Ultimate JS Course Playlist: • JavaScript Tutorials for Beginners in… ►Checkout my English channel here: / @programmingwithharry ►Instagram: www.instagram.com/codewithharry python, C, C++, Java, JavaScript and Other Cheetsheets [++]: Playlist: • Coding CheatSheets 🧾 by CodeWithHarry ►Learn in One Video[++]: Python[15 Hr] - • Python Tutorial For Beginners In Hind… Python Advance[3.5 Hr] - • Python Programming Course in Hindi (A… Python[1 Hr] - • Learn Python In Hindi In One Video - … Python[2 Hr] - • Python Tutorial In Hindi 🔥 Python[15 Min] - • 15 Minute Python Tutorial For Beginne… JavaScript[1 Hr] - • JavaScript Tutorial C[1.3 Hr]- • C Programming Tutorial For Beginners:… php[1 Hr] - • Learn Php In One Video In Hindi - हिं… php[2.3 Hr] - • Php Tutorial for Beginners in Hindi w… php[Project]- • Login And Registration Form Using Php… HTML[30 Min] - • HTML 5 Tutorial For Beginners In Hind… CSS[8.5 Hr] - • CSS Tutorial In Hindi (With Notes) 🔥 CSS[1.4 Hr] - • CSS 3 Tutorial For Beginners: Learn C… Wordpress[3.2 Hr] - • How To Make a WordPress Website | Wor… Angular[2 Hr] - • Angular Tutorial in Hindi Java[2.3 Hr] - • Java tutorial in hindi 🔥 Web Scraping[1 Hr] - • Web Scraping Tutorial using Python an… MongoDB[2 Hr] - • MongoDb Tutorial For Beginners in Hin… Numpy[1 Hr] - • Numpy Tutorial in Hindi Android Dev[12 Hr]- • Android Development Tutorial For Begi… Linux[1 Hr] - • Linux Tutorial For Beginners in Hindi JQuery[1.1 Hr] - • jQuery Tutorial For Beginners In Hind… Git and GitHub[1.1 Hr] - • Git \u0026 GitHub Tutorial For Beginners I… ►Complete course [playlist]: React - • React Js Tutorials in Hindi Python- • Python Tutorials For Absolute Beginne… OOP Python- • Object Oriented Programming Tutorials… Java - • Java Tutorials For Beginners In Hindi JavaScript- • JavaScript Tutorials In Hindi PHP- • PHP Tutorials in Hindi C- • C Language Tutorials In Hindi C++- • C++ Tutorials In Hindi Git \u0026 GitHub- • Git and GitHub Tutorials In Hindi Android Dev- • Android Development Tutorials in Hindi Python GUI- • Python GUI: Tkinter Tutorial In Hindi… Web Development- • Web Development Tutorials For Beginne… Python Django - • Python Django Tutorials In Hindi Projects Using HTML, CSS \u0026 Javascript- • Projects Using HTML, CSS \u0026 JavaScript… Data Structure and Algo - • Data Structures and Algorithms Course… Follow Me On Social Media ►Website (created using Django Rest \u0026 Angular) - https://www.codewithharry.com ►Facebook - https://www.facebook.com/CodeWithHarry ►Instagram - https://www.instagram.com/codewithharry/ Twitter - https://twitter.com/CodeWithHarry Comment “#HarryBhai” if you read this 😉😉
Content
0 -> Today we will talk about some array methods
2.915 -> There are some array methods that help you to change the array
8.576 -> You can push the elements, i.e put them in the array
11.472 -> You can take elements out of the array
14.134 -> You can even see how many elements are there in an array by using the .length property
20.8 -> There are many more such methods of arrays that you must know
24.572 -> That I'm going to tell you guys; let's go to the computer screen.
27.234 -> Let's take a look at all these methods
28.929 -> Let's get started.
36.209 -> So guys in the last video we saw the introduction of an array
38.914 -> We saw what an array is; why it's used
42.344 -> We saw some of the basics of an array.
44.325 -> Today we're going to take a look at some methods of an array
46.554 -> And I've written some methods for you guys.
49.603 -> So I'll quickly make a Repl and in that Repl we'll look at some array methods
55.302 -> I've put all the Repls in the Ultimate Java Script Codes
58.58 -> So I've made a Repl for the 17th video
62.372 -> And this one is going to be about array methods, okay?
65.561 -> So in this Repl on array methods, we're going to discuss some methods.
70.249 -> I'll do one thing, first of all I'll make an array called num, okay?
73.774 -> And in that, I'll put 1...2...3...assume 34...and 4. Okay?
81.324 -> And as soon as you press CTRL S in Replit, it does the formatting
84.163 -> I'll tell you if you don't know; many people were asking me how formatting is done.
88.089 -> So I'm just telling those people.
89.879 -> The first method that I want to tell you is toString.
92.679 -> If you want to convert any array into a string
95.034 -> Then you simply have to do num.toString.
98.4 -> Assume I'm writing here, 'let b= num.toString,'
102.933 -> Okay? So as soon as I do num.toString,
106.064 -> 'b is now a string.' Okay? b is a string.
109.761 -> And if I do console.log(b), then it will simply
114.467 -> It will run the method.
116.906 -> And here 1,2,3,34,4 will printed...like this. Okay?
121.404 -> Just like you saw now.
123 -> So toString converts an array into a string
126.472 -> Now I'll tell you about the join method
128.492 -> What does the join method do?
130.168 -> The join method joins all the elements of an array using a separator.
135.181 -> It uses a separator to join
137.772 -> So what we'll do here is
139.782 -> First of all, we'll make an array; that is already there above.
142.613 -> Here I'll write, 'let c='
146.411 -> And here I'll write, 'num.join'
150 -> And here I'll write, assume, underscore. Okay?
153.226 -> Now here if I do console. log(c),
156.79 -> Then you can see, 1_2_3_34...4 will be printed.
164.147 -> Why will this happen? This will happen because
166.547 -> Because when we join n. then it joins it, with this as a joiner.
172.132 -> Just as you can see here. Okay?
174.38 -> So this will return a string if I do a type of c
177.6 -> Assume that along with c, I also do type of c
180.567 -> Then what will happen? It will be a string.
182.767 -> And the same goes for b also.
184.443 -> If I do type of b, then that will also be a string.
187.53 -> Okay, so you should know this thing.
189.186 -> This is a string and this is also a string. Okay?
191.491 -> If I directly do 'type of' for an array then it will be an object; like we saw in the last video.
196.484 -> So if you want to print it in this way, then you can. Okay?
200.429 -> In place of the underscore, we could have written and, space
203.382 -> 1 and 2 and 3 and 4 will be printed like this.
207.251 -> So sometimes you may need to format the string
211.29 -> And you may want to print the strings in this format, okay?
215.693 -> If you want to print the string in this format, then you can.
219.886 -> Okay?
221.397 -> So this was the join method.
222.704 -> Now we'll talk about the pop method and this takes out the last element from the array
228.155 -> And updates the original array.
230.727 -> Now see, listen to two things
232.613 -> So sometimes what happens is that in an array,
234.615 -> Some methods are there that return a new array.
238.734 -> There are some arrays that change the same array.
243 -> Pop is one of those methods that changes the same array
246.567 -> Meaning that here if I just run it once; num.pop
250.711 -> Okay?
252.334 -> If I run num.pop and now if I do console.log(num)
256.648 -> Then what will happen?
258.263 -> If I do console.log(num) then you can see
262.1 -> 1,2,3,34 is coming and 4 is removed.
264.667 -> So what does pop mean?
266.133 -> To remove; to pop out.
268.972 -> If I put a ball inside a box and I take it out
272.034 -> It will be called popping it out of the box. Okay?
275.334 -> So this is what popping means.
277.334 -> Okay so what does this return do?
278.705 -> If I write here, 'let r =' okay?
283.168 -> And I also print 'r', this is returns the popped element.
287.4 -> So it will return 4; just as you can see. Okay?
291.301 -> So I'll write here...
293.758 -> pop returns the...popped element. Okay?
298.428 -> So I hope you've understood this.
300.496 -> Now let's tak about the next method--look I've written all this here for your reference.
304.182 -> I'll tell you one more thing; you don't have to rote learn every method of the Java script.
308.775 -> Sometimes you will forget some of the methods;
310.775 -> Sometimes you will forget with method modifies the original array
315.349 -> And which method returns a new array.
318.867 -> At this time, you needn't worry at all; you can run a Google search or refer to my notes.
324.192 -> This is one thing
325.012 -> So another thing is that I haven't written all the methods here, okay?
328.233 -> I've written those that will be used the most
330.824 -> So if you want to know any method, if it exists for an array
334.712 -> You can run a Google search and increase your knowledge.
337.367 -> Sometimes it will happen that you might find out a new method of an array
340.378 -> So in this way your knowledge will increase
342.473 -> Whenever there's something that you 100% don't know, okay?
346.57 -> You might know it at 95% or 96%
349.534 -> And the more you work on it, the more knowledge you will have.
354.157 -> Today even I keep learning something new about programming and I learn every day, okay?
358.434 -> So remember this thing guys,
359.671 -> You can't rote learn it, first of all
361.023 -> Google is your friend
362.489 -> All you have to do is make sure that you're worthy to make good applications
366.51 -> Okay? You have to be capable enough.
368.605 -> So pop is a method that updates the original array and returns the pop value
373.484 -> Let's talk about push. What will push do?
375.408 -> It will modify the original array and return a new array length.
379.524 -> So how we talked about the pop method,
381.848 -> Similarly, we can push it too, okay?
385.526 -> So I'll do one thing, I'll comment out this
388.708 -> And... 'push returns the new array length'
395.9 -> Okay? So I wrote here that push returns the new array length
398.267 -> And if I do r = push and after that, let us say I push 56,
405.339 -> What will happen?
407.339 -> First of all, what was its length?
408.729 -> It was 5, now it's 6. Okay?
411.381 -> And what will numb become?
413.439 -> See 56 has been added to numb as you can see
417.11 -> Okay?
417.934 -> Push will put the element that you've pushed at the end. Okay?
422.375 -> So this was push.
424.375 -> Now let's talk about shift and unshift
427.365 -> What does shift do? Shift removes the first element and returns it
432.15 -> Shift is a very simple method
435.466 -> Okay so I'll quickly write here, 'let r = num.shift,' okay?
441.566 -> If I do console.log(r), then you can see that 1 is printed.
451.667 -> Why is 1 printed? Becuase this got popped out.
453.453 -> If it was 10 then 10 would get printed. Okay?
455.8 -> So I removed one element
459 -> And will it modify the original array?
462.221 -> Will it modify the original array?
463.897 -> Meaning, will the new array be 2,3,34, 4?
467.174 -> The answer is yes, it will; like we you can see here.
469.632 -> This is the method that modifies the original array.
472.934 -> So what will it do? It will remove the first element and return it.
476.841 -> And it will modify the original array.
479.337 -> Now will talk about unshift.
481.146 -> What will unshift do? It will add a new array,
483.68 -> The way shift removed an array; unshift will add an array. Okay?
487.968 -> So I'll write here, 'Removes an element from the start of an array.'
498.471 -> Okay?
499.595 -> And this unshift, what will it do?
505.163 -> Unshift will add an element to the beginning of the array.
512.082 -> So assume that I want to add 78 to the array,
514.082 -> First of all, I'll have to comment this out, otherwise I'll get an error.
516.94 -> It'll ask why you're making r again. Okay?
519.093 -> See, it says 'identifier r has already been declared.'
522.408 -> So I'll run this and you guys can see, the first thing he returned is 6.
525.782 -> Meaning that it returned the length of the new array. Okay?
529.097 -> It returned 6 and told me the array; it added 78 in the starting.
534.234 -> So it returns the new array length.
536.425 -> You have to remember this. Okay?
537.815 -> Here it says, 'Returned new array length.'
540.463 -> So it this is very similar to the push-pop method.
544.732 -> What was the push method? That it modifies the original array and returns the length of the new array.
550.165 -> What was the pop method? That it updates the original array and returns the popped value.
554.777 -> Here it's similar to that, okay?
556.91 -> This too removes the element and returns it.
559.139 -> So the only thing is that pop removes it from the end of the array and
561.583 -> Shift removes it from the beginning. Okay?
563.699 -> So I hope you guys must have understood all these methods.
565.828 -> In the upcoming videos we will discuss more methods.
568.514 -> If you haven't accessed this playlist yet, then please do access it.
572.173 -> That's it for this video guys.
574.25 -> All the PDFs, the Replit link, everything has been put in the description box
578.595 -> You can access it.
579.47 -> Thank you so much guys for watching this video
582 -> And I will see you next time.
Source: https://www.youtube.com/watch?v=BLIrBThPTXc