Join two arrays :-. genius student


  • The concat() method is used to join two or more arrays.
  • This method does not change the original arrays, but returns a new array.
  • The new array containing the values of the joined arrays.

Syntax
concat(arrayname1,arrayname2.

Code



<!DOCTYPE html>
<html>

<head>
 <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

 <h1>join two array using concat()</h1>

 <input type="button" onclick="ar_jn();" value="Concat two array">

 <script>
  function ar_jn()
  {
   var ar1 = ["A", "B", "C"];
   var ar2 = ["D", "E", "F"];

   alert("ar1 : " + ar1);
   alert("ar2 : " + ar2);

   alert("ar1 and ar2 : " + ar1.concat(ar2));

  }
 </script>

</body>

</html>
Join two arrays :-. genius student Join two arrays :-. genius student Reviewed by Network security on October 06, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.