We would like to know how to merge two array to create two dimensional array.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from w ww .j av a 2s.co m-->
var xArray = ['x1','x2','x3','x4'],
yArray = ['y1','y2','y3','y4'];
var points = xArray.map(function(itm, i) {
return [itm, yArray[i]];
});
document.writeln(JSON.stringify(points))
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: