Different Array Methods in JavaScript
Hi there! Welcome to my blog. In this post, we will be looking into different kinds of array methods in JavaScript. Let's first see how to declare an array with 5 elements in JavaScript: const fruits = [ "Mango", "Apple", "Banana", "Orange", "Kiwi"]; Let's now understand the direction of array: End / Back of the array : In the above example, the element "Kiwi" is placed at end or back of the array. Front of the array: In the above example, the element "Mango" is placed at the front of the array. Let's now learn different array methods: push() - It adds one element to the end of the array. Every push operation makes changes in the original array. pop() - It removes the last element from an array and returns that element. Every pop operation makes changes in the original array. Either you can store the value returned from pop operation to a variable or just pop it. shift() - It removes the first element f...