JavaScript - Delete Element from the Beginning of JS Array Last Updated : 14 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. JavaScript const a = [1, 2, 3, 4]; // Remove the first element a.shift(); console.log(a); Output[ 2, 3, 4 ] 2. Using splice() methodThe splice() method is used to remove elements by specifying index and count. JavaScript const a = [1, 2, 3, 4]; // Remove the first element a.splice(0, 1); console.log(a); Output[ 2, 3, 4 ] 3. Using Destructuring AssignmentArray destructuring is used to extract the first element and create a new array with the rest elements. JavaScript const a1 = [1, 2, 3, 4]; // Skip the first element const [, ...a2] = a1; console.log(a2); Output[ 2, 3, 4 ] 4. Using Custom MethodThe idea is to start from the second element and shift all the elements one position to the left. After shifting all the elements, reduce the array size by 1 to remove the extra element at the end. JavaScript const a = [1, 2, 3, 4]; for (let i = 0; i < a.length - 1; i++) { a[i] = a[i + 1]; } // Adjust length to "delete" last element a.length = a.length - 1; console.log(a); Output[ 2, 3, 4 ] Comment More infoAdvertise with us Next Article Remove Duplicate Elements from JavaScript Array A amit_singh27 Follow Improve Article Tags : JavaScript Web Technologies javascript-array Similar Reads 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 Elements from an Index in JS Array These are the following ways to delete elements from a specified Index of JavaScript arrays:1. Using splice() MethodThe splice() method is used to remove elements directly from a specified index in an array by specifying the index and the number of elements to delete.JavaScriptlet a = [1, 2, 3, 4, 5 1 min read Remove Duplicate Elements from JavaScript Array To Remove the elements from an array we can use the JavaScript set method. Removing duplicate elements requires checking if the element is present more than one time in the array. 1. Using JavaScript Set() - Mostly UsedThe JavaScript Set() method creates an object containing only unique values. To r 3 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 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 from a Given Position of JS Array These are the following ways to delete an item from the given array at given position: 1. Using the splice() Method(Most efficient for in-place modifications)The splice() method is the most versatile way to remove elements from any position in an array. It allows you to specify the index where the r 2 min read Like