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 unshift() Method - GeeksforGeeks JavaScript Array unshift() MethodLast Updated : 15 Jul, 2024 JavaScript Array unshift() Method is used to add one or more elements to the beginning of the given array. This function increases the length of the existing array by the number of elements added to the array. Syntax:array.unshift(element1, element2, ..., elementX);Parameters:
Return value:This function returns the new length of the array after inserting the arguments at the beginning of the array. Example 1: Below is an example of the Array unshift() method.
Output 5 [ 'GeeksforGeeks', 'GFG', 'Geeks', 'for', 'Geeks' ] Example 2: In this example, the function unshift() adds 28 and 65 to the front of the array.
Output 6 [ 28, 65, 23, 76, 19, 94 ] Example 3: In this example, the unshift() method tries to add the element of the array, but the array is empty therefore it adds the value in the empty array.
Output 1 We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article. 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. |