Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27060 > unrolled thread

Strings vs Arrays and their use.

Started byjonas.thornvall@gmail.com
First post2015-03-17 01:55 -0700
Last post2015-03-17 01:55 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  Strings vs Arrays and their use. jonas.thornvall@gmail.com - 2015-03-17 01:55 -0700

#27060 — Strings vs Arrays and their use.

Fromjonas.thornvall@gmail.com
Date2015-03-17 01:55 -0700
SubjectStrings vs Arrays and their use.
Message-ID<73bece66-ea4e-4d0f-8370-cae9873bacba@googlegroups.com>
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?

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web