Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32686
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2017-03-04 15:11 -0800 |
| References | <980da03d-c451-40b0-80fd-154b3ed88eb2@googlegroups.com> <bc338550-9213-4493-921a-3818db7e4180@googlegroups.com> <XnsA72EF313A3B2Feejj99@194.109.6.166> |
| Message-ID | <e454fb0e-fed3-40c8-a963-4aa1d2a7e7db@googlegroups.com> (permalink) |
| Subject | Re: Copy full array element. |
| From | jonas.thornvall@gmail.com |
Den lördag 4 mars 2017 kl. 23:53:44 UTC+1 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 04 Mar 2017 in comp.lang.javascript:
>
> >> function reOrderArr(){
>
> function reOrderArr(t){
>
> >> arr[t]=arr[arr.length-1];
> >> arr.pop();
> >> }
> >
> > In the case above arr.pop(); will not remove any element, nor will it do
> > the copy. Array size stay the same i get no error messages in console
> > but nothing happen.
>
> Works fine here:
>
> <script type='text/javascript'> 'use strict'
>
> let arr = ['a','b','c'];
> document.write(arr + '<br>'); // a,b,c
>
> reOrderArr(0);
> document.write(arr + '<br>'); // c,b
>
> function reOrderArr(t){
> arr[t] = arr[arr.length-1];
> arr.pop();
> };
>
> </script>
>
>
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
Well i tried it but it doesn't work i had to do like this.
function reOrderArr(t) {
arr[t].nodelinks = arr[arr.length - 1].nodelinks;
arr[t].hold = arr[arr.length - 1].hold;
arr[t].rposX = arr[arr.length - 1].rposX;
arr[t].rposY = arr[arr.length - 1].rposY;
arr[t].rwidth = arr[arr.length - 1].rwidth;
arr[t].rheigth = arr[arr.length - 1].rheigth;
arr[t].rcolor = arr[arr.length - 1].rcolor;
arr[t].bcolor = arr[arr.length - 1].bcolor;
arr[t].print = arr[arr.length - 1].print;
last=arr.length-1;
arr.pop();
for (var s=0;s<arr.length;s++){
for (var v=0;v<arr[s].nodelinks.length;v++){
if (arr[s].nodelinks[v]==last) arr[s].nodelinks[v]=t;
}
}
}
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Copy full array element. jonas.thornvall@gmail.com - 2017-03-04 13:55 -0800
Re: Copy full array element. jonas.thornvall@gmail.com - 2017-03-04 14:02 -0800
Re: Copy full array element. jonas.thornvall@gmail.com - 2017-03-04 14:28 -0800
Re: Copy full array element. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-03-04 15:35 -0800
Re: Copy full array element. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-03-04 23:53 +0100
Re: Copy full array element. jonas.thornvall@gmail.com - 2017-03-04 15:11 -0800
Re: Copy full array element. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-03-05 10:40 +0100
csiph-web