![]() |
VOOZH | about |
The Array.unshift() method in TypeScript is an inbuilt function used to add one or more elements to the beginning of an array. It modifies the original array and returns the new length of the array.
array.unshift( element1, ..., elementN )This method accepts n number of similar elements.
Example 1: Adding a Single Element
Output:
4
[1,2,3,4]
Example 2: Adding Multiple Elements
Output:
8
["G", "e", "e", "k", "s", "f", "o", "r"]