GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript Array shift() Method - GeeksforGeeks JavaScript Array shift() MethodLast Updated : 18 Sep, 2024 The shift() method in JavaScript is used to remove the first element of an array, reducing the array's length by one. This method is particularly useful for scenarios where elements need to be processed in the order they were added, such as in queue-like structures. Syntax:arr.shift();Parameters:
Return Value:
Key Points
Examples of Array shift() MethodExample 1: Removing the First Element from the ArrayThe function
Output GFG [ 'Geeks', 'for', 'Geeks' ] Example 2: Removing First Element from Empty ArrayThe function
Output undefined [] Example 3: Removing the First Element from the Nested ArrayThe function func() removes the first element from the nested array using the shift() method. The removed element is stored in the variable value, which is then logged to the console along with the modified array.
Output 2 Array after operation: 1,3,4,5,6 Supported Browsers:
Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |