Array.push(item1, item2 …)
Parameters: Items to be added to an array.
- Description: This method is used add elements at the end of an array.
- Array.unshift() : Adding elements at the front of an Array
Array.unshift(item1, item2 …)
Parameters: Items to be added to the array
- Description: This method is used to add elements at the beginning of an array.
- Array.pop() : Removing element from the end of an array
Array.pop() Parameters: It takes no parameter
- Description: It is used to remove array elements from the end of an array.
- Array.shift() : Removing elements at the beginning of an array
Array.shift() Parameter : it takes no parameter
- Description : It is used to remove array at the beginning of an array.
- Array.splice() : Insertion and Removal in between an Array
Array.splice (start, deleteCount, item 1, item 2….) Parameters: Start : Location at which to perform operation deleteCount: Number of element to be deleted, if no element is to be deleted pass 0. Item1, item2 …..- this is an optional parameter . These are the elements to be inserted from location start
- Description: Splice is very useful method as it can remove and add elements from the particular location.
Note :All the above examples can be tested by typing them within the script tag of HTML or directly into the browser’s console.
This article is contributed by Sumit Ghosh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.