11 JavaScript Array Methods You Should Know:

11 JavaScript Array Methods You Should Know:

Array methods are considered the most important part of JavaScript.If you don't know how to use Array methods this article will guide you.

  • Popping and Pushing() when you work with an array it is easy to remove elements and to add new elements.

carbon (7).png

  • Shifting Elements() Removes the first element of an array.

carbon (8).png

  • Changing Elements . Array elements are accessed using their index number.

carbon (9).png

. The length property provides an easy way to append a new element to an array.

carbon (10).png

  • Deleting Elements Elements can be deleted by using the JavaScript operator delete.

carbon (11).png

  • Splicing an Array The splice method can be used to add new items to an array.

carbon (12).png The first parameter(2)defines the position where new elements should be added(spliced in), the second parameter (0) defines how many elements should be removed. The parameters ("lemon","kiwi") define the new elements to be added.

  • Using splice() to remove Elements.

carbon (14).png

  • The sort() method sorts an array alphabetically.

carbon (15).png

  • Reversing an Array The reverse()reverses the elements in an array.

carbon (16).png

  • Joining Arrays The concat() method creates a new array by concatenating two arrays.

carbon (17).png

  • Slicing an Array The slice() method slices out a piece of an array.

carbon (20).png