DEV Community

Akash
Akash

Posted on

Basic Array Methods in JS

  • Basic Array methods in java script are

  • Array length

  • Array to string()

  • Array at()

  • Array join()

  • Array pop()

  • Array push()

  • Array shift()

  • Array unshift()

  • Array is Array()

  • Array delete()

  • Array concat()

  • Array copywithin()

  • Array flat()

  • Array slice()

  • Array splice()

  • Array to spliced()

EXPLANATION:

1.Array length

  • It returns a length of an array and also used to set length of array


OUTPUT=3
2.Array to string()

  • To string methods is used to join multiple string in array as single string with comma .

OUTPUT= Rx100,RE Duke

3.Array at()

  • At is used to returns the indexed element

OUTPUT:RE

4.Array join()

  • This method used to join all elements into string


OUTPUT=RX100*Re*Duke

5.Array pop()
*This method is used to remove last element from array


OUTPUT:["Rx100","Re"]

6.Array push ()

  • This method used a add a new element at the end in array .


OUTPUT=["Rx100","RE","Duke","Jawa"]

7.Array shift()

  • This method removes the first element in array and remains other elements in ordered index


OUTPUT=["Re","Duke","jawa"]

8.Array unshift()

  • This method is used to add new elements in beginning of array and remains other elements in uppercase ordered index


OUTPUT=["Dukati","Rx100","RE","Duke","Jawa"]

9.Array is Array()

  • This method is used to define wether the given array is array of string or number
  • It denotes true or false


OUTPUT:True

10. Array delete()

  • This method is used to delete element in array by index and it remains a deleted space undefined.


OUTPUT=["Rx100","Duke","Jawa"]

11.Array concat()

  • This method is used to create new array by already existing 2 different arrays


OUTPUT=["Rx100","RE","Duke","Jawa","Bmw","Tesla"]

12.Array Flat

  • This method is used to create a single array with sub arrays like concat method


OUTPUT =[2,5,1,7,1,2]

13. Array splice

  • This method used to add new elements to array

  • First parameter (2) denotes where the value store,and second parameter(0) denotes how many elements should be removed OUTPUT =[apple","mango","kiwi","grape","orange"]

14. Array slice

  • This method is used to slice a element from array from accurate index number


OUTPUT=[Lemon","Apple","Mango"]

Top comments (0)