user3767164 user3767164 - 7 months ago 40
jQuery Question

Split a 2D array into single arrays

I am bit new in JQuery ,,I have a 2D Array

2DArray =[2.0,6.31]

I want to split it into 2 One dimensional Array like this:

[2.0, 3.0, 4.0]
[6.31, 6.09, 7.44]

I have read posts about convert single array into multidimensional array but not vice versa ...

Any suggestion would be helpful


This should about do it, you have to loop:

var twoDArray =[[2.0,6.31],

var xArray = [];
var yArray = [];

$.each(twoDArray, function(index, value) {

BTW 2DArray is an invalid variable name. You can't use 2 at the start of a variable.

Also your array declaration is invalid.