, - Array, , . :
var index, length;
var result = [];
// assertion: arrayA.length === arrayB.length
result.length = arrayA.length; // Helps performance in some implemenations, harmless in others
for (index = 0, length = arrayA.length; index < length; ++index) {
result[index] = arrayA[index] + arrayB[index];
}
( stringA → arrayA stringB → arrayB).
, undefined ( , JavaScript ), , :
var index, length, Apresent, Bpresent;
var result = [];
result.length = Math.max(arrayA.length, arrayB.length); // Helps performance in some implementations, harmless in others
for (index = 0, length = result.length; index < length; ++index) {
Apresent = arrayA.hasOwnProperty(index);
Bpresent = arrayB.hasOwnProperty(index);
if (Apresent && Bpresent) {
result[index] = arrayA[index] + arrayB[index];
}
else if (Apresent) {
result[index] = arrayA[index];
}
else if (Bpresent) {
result[index] = arrayB[index];
}
}
, , .