Array Connection concat ()
The Concat () method is used to concatenate two or more arrays. This method returns a new array without changing the original array.
Grammar
Arrayobject.concat (array1,array2,..., Arrayn)
Parameter description:
We create an array that will connect the parameters in Concat () to the array Myarr, with the following code:
<Scripttype= "Text/javascript"> varMya= NewArray (3); mya[0] = "1"; mya[1] = "2"; mya[2] = "3"; document.write (Mya.concat (4,5)+"<br>"); document.write (MYA); </Script>
Operation Result:
1,2,3,4,51,2,3
We created three arrays and then used Concat () to connect them together with the code as follows:
<Scripttype= "Text/javascript"> varmya1= NewArray ("hello!") varMYA2= NewArray ("I"," Love"); varMya3= NewArray ("JavaScript","!"); varmya4=Mya1.concat (MYA2,MYA3); document.write (MYA4);</Script>
Operation Result:
hello!,i,love,javascript,!
JS in array connection concat ()