Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27445
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Overflow, integers and strings |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | (2 earlier) <66061bf2-9092-42a5-918e-5a039a53db20@googlegroups.com> <XnsA48C8AB5EE74Ceejj99@194.109.133.246> <6ca07e69-1694-49c1-93eb-748c44d8ab68@googlegroups.com> <XnsA48CD1D512C3Beejj99@194.109.133.246> <b378aebc-5acc-4b88-9050-6b812221cba9@googlegroups.com> |
| Date | 2015-05-01 10:48 +0200 |
| Message-ID | <XnsA48D6DDF66B5Feejj99@194.109.133.246> (permalink) |
jonas.thornvall@gmail.com wrote on 01 mei 2015 in comp.lang.javascript:
> After comparisson, if the result is smaller then i have to swap the
> content of the arrays, because the next function call require to be fed
> in order, next(bigArr,smallArr(.
>
> Maybe a bit naive i thought this would work.
>
> var tempArr = [];
Not needed!
"tempArr=subTwo" will make it an array,
independent of what it was earlier.
Remember a variable name is just a pointer to the internal structure.
> res=arrCompare(subOne,subTwo);
> if(res==true){tempArr=subTwo; subTwo=subOne;subOne=tempArr;}
(res==true) ?
Why not just (res) ?
Build and think modular:
function arraySwap(a, b) { // 2 different arrays expected
var tempArrName = b;
b = a;
a = tempArrName;
// the name tempArrName will be garbagecollected automagically
};
function arraySwapIfSmaller(a, b) { // arrays by reference
if (arrCompareSmaller(a, b))
arraySwap(a, b);
};
> The subOne to subTwo work just fine,
> but it seem like tempArrs index not
> of integer type. When i look at the swapped arrays they look correct.
> But when i perform arithmetic operations it is obvious that somethings
> wrong.
>
> How can i initialize the indexes of tempArr to be integers?
I don't understand.
What does "initializing an index"
and "initializing to be integer [type]" mean?
===================
Array indexes are ALWAYS integers,
however arrays can also be used as an object:
var a = ['first','second'];
var b = a;
a[2.3] = 'not an array member';
b['blah'] = 'not an array member too';
alert(a.length); // 2
alert(b.length); // 2
alert(a.blah); // 'not an array member too'
alert(b[2.3]); // 'not an array member'
So 1: the array index behavour is not touched
even when assigning object properties to it.
So 2: there is only one array, with two variable names!
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 00:11 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 01:29 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 03:31 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 03:33 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-30 13:38 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 08:20 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-30 20:37 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 23:46 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 01:01 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 01:47 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 10:50 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 02:04 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-01 11:08 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 04:43 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 04:46 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 10:48 +0200
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-01 10:58 +0100
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 14:34 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-01 14:47 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-01 15:04 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:18 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:24 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 06:49 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:17 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:21 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 07:37 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 11:27 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 12:34 -0700
Re: Overflow, integers and strings Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-01 22:42 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-01 23:37 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-02 00:19 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-02 05:50 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-02 14:21 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 04:30 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 07:12 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-03 16:45 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 09:17 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-03 09:22 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 03:38 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 14:01 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 06:41 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:39 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:48 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 06:49 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:25 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:26 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:59 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 00:59 +0100
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:28 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:34 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-04 15:41 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:52 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 08:03 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 17:56 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:04 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:21 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:38 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:07 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:25 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:43 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:46 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:11 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 12:53 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:23 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:40 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:12 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:06 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:39 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:42 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 13:40 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:47 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:30 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-04 23:33 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 15:53 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:51 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 18:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 18:22 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-04 21:38 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 18:37 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 14:00 -0700
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 09:19 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:24 +0200
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 21:37 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 21:56 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 13:21 -0700
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 22:38 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 22:46 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-04 22:57 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:17 +0200
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 00:45 +0100
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-06 00:01 +0200
Re: Overflow, integers and strings Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-05 08:14 +0200
Re: Overflow, integers and strings "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-05 23:54 +0200
Re: Overflow, integers and strings wolfgang zeidler <invalid@invalid.invalid> - 2015-05-04 23:18 +0200
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-04 23:53 +0200
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 16:06 -0700
Re: Overflow, integers and strings "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-05 10:26 +0200
Re: Overflow, integers and strings Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-05-05 19:59 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-04 07:40 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-05 01:10 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-05-01 05:03 -0700
Re: Overflow, integers and strings Ben Bacarisse <ben.lists@bsb.me.uk> - 2015-04-30 20:36 +0100
Re: Overflow, integers and strings jonas.thornvall@gmail.com - 2015-04-30 13:08 -0700
Re: Overflow, integers and strings Scott Sauyet <scott.sauyet@gmail.com> - 2015-04-30 10:52 -0700
csiph-web