i have a problem about how to joining two arrays like this?
var arrayA = [a,b,c,d,e]
var arrayB = [1,2,3,4,5]
result : [ [a,1], [b,2], [c,3], [d,4], [e,5] ]
(In angularjs)
You could try below
var arrayA = [a,b,c,d,e],
arrayB = [1,2,3,4,5]
var output = arrayA.map(function(value, index){
return [ value, arrayB[index]]
})
console.log(output);
OR you could go for library such as underscore.js .
Maybe not using angular just Js
var arrayA = [a,b,c,d,e];
var arrayB = [1,2,3,4,5];
var result=[];
for(i=0;i<arrayB.length;i++){
result.push([arrayA[i],arrayB[i]]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.