Concatenate means to join
two things in succession.
The concat()
method creates
a new array that contains elements
from the array on which concat
is invoked followed by
the arguments passed.
If the argument is an array,
the elements of the array will
be inserted into the new array.
In the example given above,
the array numbers
contains
the elements of
the evenNumbers
array
followed by the elements of
the oddNumbers
array.
In the example given above,
-
evenNumbers.concat(oddNumbers, 7, "Integers", true)
creates a new array
that contains the elements of evenNumbers
,
followed by the elements of oddNumbers
,
followed by the elements
7
, "Integers"
, and true
.
-
evenNumbers.concat(7, "Oliver Smith", oddNumbers, false)
creates a new array
that contains the elements of evenNumbers
,
followed by the elements 7
and "Oliver Smith"
,
followed by the elements of oddNumbers
,
followed by false
.
-
evenNumbers.concat(7, "Separator", [oddNumbers], false)
creates a new array
that contains the elements of evenNumbers
,
followed by the elements
7
, "Separator"
, [oddNumbers]
, and false
.