concat()
concat()
is a built-in method in TypeScript that allows you to join two or more arrays together and return a new array that contains all the elements of the original arrays. This method does not modify the original arrays, but instead creates a new array that is a copy of the original arrays with the new elements added to the end.
Example
In this example, we have two arrays arr1
and arr2
which contain the strings "hello" and "world" respectively. We then use the concat()
method to join the two arrays together and store the result in a new array arr3
. Finally, we log the contents of arr3 to the console, which outputs ["hello", "world"]
.
References
Last updated