The array.push() function is used to push one or more values in an array. This function changes the length of an array by the number of elements added to the array. The syntax of the function is as follows:
arr.push(element1[, ...[, elementN]])
Arguments: This function can contain as many numbers of arguments as the number of elements to be inserted into the array.
Return value: This function returns the new array with new values after inserting the arguments into the array.
array.splice(start_index, delete_count, value1, value2, value3, ...)
Note: Splice() method deletes zero or more elements of an array starting with the start_index element and replaces those elements with zero or more elements specified in the argument list.
Example: Below is the example to illustrate the use of .join() method with push() method and splice() method together:
Before clicking the Push and Splice button:
Output after clicking the Push and Remove button:
- Difference between Inner Join and Outer Join in SQL
- PHP | Ds\Deque push() Function
- PHP | Ds\Sequence push() Function
- How to push a value based on matched value in PHP ?
- Node.js | push() function
- p5.js | Push Operation on Stack
- PHP | SplDoublyLinkedList push() Function
- PHP | Ds\Vector push() Function
- TypeScript | Array push() Method
- Sending Push Notifications : Progressive Web Apps
- ConcurrentLinkedDeque push() method in Java with Examples
- Perl | Arrays (push, pop, shift, unshift)
- p5.js | join() function
- SQL Join vs Subquery
- PHP | join() Function
- PHP | Ds\Set join() Function
- Node.js | join() function
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.