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


Groups > comp.lang.javascript > #27623

Re: Swap arrays ones again.

Newsgroups comp.lang.javascript
Date 2015-05-14 07:12 -0700
References <974af16e-3a67-4d6c-944a-af27660f05a8@googlegroups.com>
Message-ID <c06cbc73-fe97-4d99-bf44-8ebe3a2532be@googlegroups.com> (permalink)
Subject Re: Swap arrays ones again.
From jonas.thornvall@gmail.com

Show all headers | View raw


Den torsdag 14 maj 2015 kl. 15:55:47 UTC+2 skrev jonas.t...@gmail.com:
> I have this problem with feeding the function in correct order.
> 
> This function work great to swap the arrays as long they really are One and Two
> 
> ->checkArrayOrder(One,Two) works fine and will swap the arrays if arrCompare return true.
> 
> 
> function checkArrayOrder(One,Two)
> {
>    res = arrCompare(One, Two) //Here i check which one bigger smaller
>    if (res)
>    {
>       document.calc.stats.value += "Swap arrays! First array operand smaller=" + res + "\n";
>       var tempArr = One.slice();
>       One = [];
>       One = Two.slice();
>       Two = [];
>       Two = tempArr.slice();
>    }
> }
> 
> ***But*** i want a more general function to swap any *GLOBAL* arrays?
> 
> checkArrayOrder(A,B) will not work and swap the arrays A and B.
> 
> 
> 
> How can i get the function to do the swap on any arrays it is fed with?

How can i make the function work on the actual arrays the function is fed with. 
Should i return the array one and two.

And then do slice once again A=One.slice();  B=Two.slice(), that just seems wrong but mayb is the way one do it?

But i can not return two arrays anyway, i am stuck. 


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


Thread

Swap arrays ones again. jonas.thornvall@gmail.com - 2015-05-14 06:55 -0700
  Re: Swap arrays ones again. jonas.thornvall@gmail.com - 2015-05-14 07:12 -0700
  Re: Swap arrays ones again. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-14 16:12 +0100
    Re: Swap arrays ones again. jonas.thornvall@gmail.com - 2015-05-14 10:17 -0700
      Re: Swap arrays ones again. jonas.thornvall@gmail.com - 2015-05-14 10:47 -0700

csiph-web