Delete the first element of array without using shift() method in JavaScript Last Updated : 22 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Given an array containing some array elements and the task is to remove the first element from the array and thus reduce the size by 1. We are going to perform shift() method operation without actually using it with the help of JavaScript. There are two approaches that are discussed below: Table of ContentMethod 1: Using splice() MethodMethod 2: Using filter() MethodMethod 3: Using slice() MethodMethod 1: Using splice() MethodWe can use the splice() method that is used to get the part of the array.Example: In this example, we will implement the above approach. JavaScript let Arr = ['Geeks', 'GFG', 'Geek', 'GeeksForGeeks']; console.log("Array: [" + Arr + "]"); function myGFG() { Arr.splice(0, 1); console.log("Elements of Array: [" + Arr + "]"); } myGFG(); OutputArray: [Geeks,GFG,Geek,GeeksForGeeks] Elements of Array: [GFG,Geek,GeeksForGeeks] Method 2: Using filter() MethodWe can use the filter() method to filter out the element at index 0.Example: In this example, we will implement the above approach. JavaScript let Arr = ['Geeks', 'GFG', 'Geek', 'GeeksForGeeks']; console.log("Array: [" + Arr + "]"); function removeFirst(element, index) { return index > 0; } function myGFG() { Arr = Arr.filter(removeFirst); console.log("Elements of array = [" + Arr + "]"); } myGFG(); OutputArray: [Geeks,GFG,Geek,GeeksForGeeks] Elements of array = [GFG,Geek,GeeksForGeeks] Method 3: Using slice() MethodWe can use the slice() method to create a new array starting from the second element.Example: In this example, we will implement the above approach. JavaScript let Arr = ['Geeks', 'GFG', 'Geek', 'GeeksForGeeks']; console.log("Array: [" + Arr + "]"); function myGFG() { Arr = Arr.slice(1); console.log("Elements of Array: [" + Arr + "]"); } myGFG(); OutputArray: [Geeks,GFG,Geek,GeeksForGeeks] Elements of Array: [GFG,Geek,GeeksForGeeks] Comment More infoAdvertise with us Next Article Delete the first element of array without using shift() method in JavaScript P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads Which one method use to delete an element from JavaScript array (slice or delete) ? We can use both methods to delete an element from a javascript array. Â The answer is solely dependent on the application and on the programmer. What slice() method does? The slice method, as the name suggests, slices an array and returns a copy of the new array. This method does not affect the main 4 min read How to remove specific elements from the left of a given array of elements using JavaScript ? In this article, we will learn How to remove specific elements from the left of a given array of elements using JavaScript. We have given an array of elements, and we have to remove specific elements from the left of a given array. Here are some common approaches: Table of Content Using splice() met 2 min read How to delete an element from an array using JavaScript ? The array is a type of data structure that allows us to store similar types of data under a single variable. The array is helpful to create a list of elements of similar types, which can be accessed using their index. In this article, we will discuss different ways to remove elements from the array. 5 min read Find the min/max element of an Array using JavaScript To find the minimum or maximum element in a JavaScript array, use Math.min or Math.max with the spread operator.JavaScript offers several methods to achieve this, each with its advantages.Using Math.min() and Math.max() Methods The Math object's Math.min() and Math.max() methods are static methods t 2 min read JavaScript - Delete First Occurence of Given Element from a JS Array These are the following ways to delete elements from a specified Index of JavaScript arrays:1. Using indexOf() and splice() - Most UsedThe indexOf() method finds the first occurrence of the element in the array, and splice() removes it at that index. This approach directly modifies the original arra 2 min read JavaScript - Delete Elements from the End of a JS Array These are the following ways to delete elements from the end of JavaScript arrays:1. Using pop() methodThe pop() method is used to remove the last element from an array and returns the modified array.JavaScriptlet a = [1, 2, 3, 4]; // Remove last element a.pop(); console.log(a);Output[ 1, 2, 3 ] 2. 2 min read JavaScript - Delete Element from the Beginning of JS Array These are the following ways to delete elements from JavaScript arrays:1. Using shift() method - Mostly UsedThe shift() method removes the first element from the array and adjusts its length.JavaScriptconst a = [1, 2, 3, 4]; // Remove the first element a.shift(); console.log(a);Output[ 2, 3, 4 ] 2. 2 min read Which built-in method removes the last element from an array and returns that element in JavaScript ? In this article, we will know how to remove the last element from an array using the built-in method in Javascript, along with understanding its implementation through the examples. There are a few Javascript built-in methods and techniques with which we can remove the last element of the array. We 3 min read What is the difference between unshift() and Push() method in JavaScript? JavaScript Unshift() method is very much similar to the push() method but the difference is that the unshift() method adds the elements at the very beginning of the array whereas the push() method adds at the end of the array. Javascript Array unshift() method: The JavaScript Array unshift() Method 2 min read Swapping two array elements in a single line using JavaScript In JavaScript, there exist many ways by which one can swap two array elements. In this article, we will discuss a way in which one can swap two array elements in JavaScript in a single line. The input and output would be as follows. Input: arr = { 10, 20, 40, 30 }Output: arr = { 10, 20, 30, 40 } // 3 min read Like