shift Summary Removes the first element of the array. Usage public T+ shift() Returns The first element of the array that was removed or undefined if there were no elements in the array. Description Removes the first element of the array and returns the element. If there are no elements in the array, undefined is returned. This method mutates the array. Examples Basic Usage 123456import System; int[] arr = [ 1, 2, 3, 4 ];Console.log(arr.first()); // 1arr.shift(); // Removes first elementConsole.log(arr.first()); // 2 Return and remove the first element of the array 123456import System; int[] arr = [ 100, 200, 300, 400];Console.log(arr.length); // 4Console.log(arr.shift()); // 100Console.log(arr.length); // 3 Share HTML | BBCode | Direct Link