Javascript Data Type How to - Merge two dimensional array into one dimensional array








Question

We would like to know how to merge two dimensional array into one dimensional array.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--   w ww  .  j  av a 2  s .c  o m-->
var id_list = [[200, 201, 202, 203],[300, 301, 302, 303]];
document.writeln('Before ' + id_list[0]);
id_list = id_list[0].concat(id_list[1]);
document.writeln('After ' + id_list);

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: