Use of Javascript Concat method

vishalneeraj-24503
Posted by vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 807
Today we will learn about Concat() in-built Javascript method.
Javascript Concat() method returns a new array consisted of existing array joined with two or more arrays.
So,it's very easy to concatenate 2 array using Javascript.

We can understand it by an example:-

<html>
<head>
</head>

<body onload="concate_arrays();">

<script type="text/javascript">
function concate_arrays()
{
var val1 = ["vishal","neeraj","kumar"];
var val2 = [10,20,30];

var text = val1.concat(val2);
alert("Concatnated text is: " + text);
}
</script>
</body>
</html>


Output will be vishal,neeraj,kumar,10,20,30

Comments or Responses

Login to post response