In this article, we will learn how to find all elements in a given array except for the first one.
Method 1: Using for loop
In this method, we will use a for loop to grab all the elements except first. We know that in an array the first element is present at index ‘0’. We will run a loop from 1 to array.length and saving those remaining elements to another array.
[ 2, 3, 4, 5 ]
Method 2: Using slice() method
The slice()It is a method that returns a slice of an array. It takes two arguments, the start and end index.
[20, 30, 40, 50]