-7

I have two arrays:

var array1= [[1],[2],[3]];
var array2= [[10],[20],[30]];

is there a way to (have) a third array?

var array3 = [[1],[10],[2],[20],[3],[30]]; 

Maybe:

var test= array1.join(array2 + "<br>");
Cœur
  • 37,241
  • 25
  • 195
  • 267
Borja
  • 3,359
  • 7
  • 33
  • 66

2 Answers2

3

I think you are looking for the "concat" function

Join two arrays:

var hege = ["Cecilie", "Lone"];
var stale = ["Emil", "Tobias", "Linus"];
var children = hege.concat(stale);

The values of the children array will be:

Cecilie,Lone,Emil,Tobias,Linus

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat

elclanrs
  • 92,861
  • 21
  • 134
  • 171
Peterson
  • 301
  • 3
  • 11
0

You can either use CONCAT function like

array1 = array1.concat(array2)

OR, APPLY()

array1.push.apply(array1, array2)
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • not function, and it is not a "concat" the true way.... :/ – Borja Jul 12 '14 at 23:11
  • You say so cause probably the order in which the items to be as in your posted code. Right? You can use a `for` loop and get the item combined but I am not sure about the order though. – Rahul Jul 12 '14 at 23:15