views:

19

answers:

1
+1  Q: 

JS Combine Arrays

Im trying to combine 2 arrays in javascript into one.

var lines = new Array("Line1","Line2","Line3");
lines = new Array("Line5","Line6","Line7");

This is a quick example, i want to be able to combine then so that when the second line is read the array can be used as lines['4'] (returning "Line5") How would i do this?

+4  A: 
var a=new Array('a','b','c');
var b=new Array('d','e','f');
var c=a.concat(b);

//c will now be an array containing: ('a','b','c','d','e','f')
Moin Zaman
Just found that function, thanks!
Diesal11
have to wait 12 mins to mark as answer
Diesal11
no worries :), you're welcome
Moin Zaman