![]() |
VOOZH | about |
The Array.push() method in TypeScript is a built-in function used to append one or more elements to the end of an array. It modifies the original array and returns the new length of the array.
Here is the syntax for using the push() method:
array.push(element1, ..., elementN)Parameter: This method accept a single parameter as mentioned above and described below:
Return Value: This method returns the length of the new array.
In this example, we add a single element to an array.
Output:
[11, 89, 23, 7, 98, 8]
6
In this example, we add multiple elements to an array.
Output:
[2, 5, 6, 3, 8, 9, 0, 5, 12, 9]
10