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


Groups > comp.lang.javascript > #27060

Strings vs Arrays and their use.

Newsgroups comp.lang.javascript
Date 2015-03-17 01:55 -0700
Message-ID <73bece66-ea4e-4d0f-8370-cae9873bacba@googlegroups.com> (permalink)
Subject Strings vs Arrays and their use.
From jonas.thornvall@gmail.com

Show all headers | View raw


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?

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web