Ich habe ein Problem darüber, wie man zwei Arrays wie folgt verbinden?Join zwei Array mit dem gleichen Index
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)
Ich habe ein Problem darüber, wie man zwei Arrays wie folgt verbinden?Join zwei Array mit dem gleichen Index
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)
könnten Sie versuchen, unter
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);
ODER Sie Bibliothek wie underscore.js gehen könnte.
Vielleicht nicht mit Winkel nur 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]]);
}
Was das eigentliche Problem? SO ist nicht für "wie mache ich ....", dafür ist Google da. Was hast du gefunden, dass dich das tun lässt, und wie hat das nicht für dich funktioniert? –
Was hast du probiert? :) –