[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Strings vs Arrays and their use.

JT

3/17/2015 8:56:00 AM

What is the main reason doing array manipulations versus string manipulations, are there less operations doing array manipulations?

When reading code i can think that there is a readability in doing string manipulations using variables rather than assigning the index of an array.

And also i wonder should one alway try do it directly between arrays?

for (i=0;i<length;i++){
sum=arrOne[i]+arrTwo[i]+remainder;
if (sum>=base) { sum=sum-base; remainder=1;} else {remainder=0;}
result[i]=sum;
}

Or this

for (i=0;i<length;i++){
result[i]=arrOne[i]+arrTwo[i]+remainder;
if (result[i]>=base) { result[i]=result[i]-base; remainder=1;}
else {remainder=0;}

}

I prefer reading the above code, but maybe it use more operations?