Is it possible to join two arrays this way?

Flavio Tiezzi
Kilo Sage

Hello guys,

Is it possible to join two arrays this way?

var arr = [ "test1", "test2", "test3" ];

var arr1 = [ "test4" ];

I need to join two arrays like this:

var arr2 =  [ "test1", "test2", "test3" , "test4"];

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello 

do like below

 arr.concat(arr1)

This will combine two arrays 

Please mark my answer correct if it helps you 

View solution in original post

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

Hello 

do like below

 arr.concat(arr1)

This will combine two arrays 

Please mark my answer correct if it helps you 

Hello mohith,

can we combine two arrays based on index

var arr1 = [a , b ,c];

var arr2 = [1,2,3];

var arr3 = {[a,1],[b,2],[c,3]};

Any answer can be appreciated.Thank yoU!

 

Rakesh Goel
Kilo Expert

You will use normal Javascript function: 

arr2 = arr.concat(arr1)

emir
ServiceNow Employee
ServiceNow Employee
Look into ArrayUtil API