Array Methods

Manish SawManish Saw
2 min read

Array. This is one of the most used data type or object in Java script and it can store values of any data type from a String to even an array. And In this blog, I am gonna to explain you 10 Most used and my Favorite array methods that you will also use, and not in those formal way with lots of complex words and tech Jargons(Complex words of Tech). So let’s Start this amazing journey.

Let’s start this journey with an Story of managing all my Employees data. So firstly we need to know how to create an array, so here is the syntax to create an array

So Now let we need to axis any element. So we can axis them using the Index number and it starts from beginning with 0. So let we wanna to print Sunny, and his index in this case is 1.

Now, we just hired two more digital marketer in our Business, so to add their name, we can use either “Push: to add any Element in last of array” or “Unshift: to add any Element in starting of array”

But just after the work of less than a Week, we found that both of them are useless. So Now we had fired them. Now to remove their name from the array we can use either “Pop: to remove the last element from array” or “Unshift: to remove the first element of our array”

Now let we wanna to sort the employees name in the alphabetical order, so to arrange them, we can use “sort” keyword.

Now I also wanna to add my marketing team array in this array or also called “Concatenation: adding two arrays and forming a single array”

Now If we wanna any part of our array, then this methos is called splicing and it’s very easy like this:

and second line is the main splicing part, and there the 0 is inclusive(means included) and 3 in excluded(means not included).

So now we wanna to know the employees we have. So we can know the length of Array using “length” method:

But this is not looking good on running, so lets use “Join: character used to join elements” in our array.

Now we wanna to add some newly joined employees name also with different way, So we can use "“push: adds elements in our array”


Hope you will like this blog. And If you found reading this blog helpful, then make sure to hit on the like icon.

0
Subscribe to my newsletter

Read articles from Manish Saw directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manish Saw
Manish Saw