Let us say, we have a Array that contains three names, Mohan, Kriti and Salim. And we want to insert a new Array with two names Sia and Andrew at the end of the Array.
There are two ways by which we can join or extend Array.
At first let us see the Joining of two Arrays using + operator.
<html> <body> <script> var x = ["Mohan", "Kriti", "Salim"] var y = ["Sia", "Andrew"] var z = x.concat(y) document.write(z) </script> </body> </html>
So, in the above code we have created a Array and initialised to the variable x.
x = ["Mohan", "Kriti", "Salim"]
Below is how the values are positioned in the Array,
Also we have another Array that contains, Sia and Andrew.
y = ["Sia", "Andrew"]
Next, we have used the concat() function to add the the Arrays x and y.
var z = x.concat(y)
And the Arrays x and yis joined and initialised to a new Array z.
And we get the below output,
Mohan,Kriti,Salim,Sia,Andrew