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


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

Comparing arraies

Started byArchos <raul.san@sent.com>
First post2012-01-26 07:23 -0800
Last post2012-01-27 16:00 +0100
Articles 3 on this page of 43 — 10 participants

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


Contents

  Comparing arraies Archos <raul.san@sent.com> - 2012-01-26 07:23 -0800
    Re: Comparing arraies Martin Honnen <mahotrash@yahoo.de> - 2012-01-26 18:29 +0100
      Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-26 19:50 +0100
        Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-26 19:54 +0100
          Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-27 16:49 +0000
            Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-27 18:41 +0100
              Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-28 11:28 +0000
                Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-28 21:17 +0100
                  Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-29 14:55 +0000
                    Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-29 17:13 +0100
                      Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-30 15:27 +0000
                        Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-30 19:03 +0100
                          Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-31 15:07 +0000
                          Re: Comparing arraies Dr J R Stockton <reply1205@merlyn.demon.co.uk> - 2012-01-31 18:51 +0000
                        Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-30 12:01 -0800
                          Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-31 11:06 +0000
                            Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-31 06:08 -0800
                              Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-01-31 16:08 +0000
                                Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-31 18:32 -0800
                                  Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-01 17:02 +0000
                                    Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-01 10:07 -0800
                                      Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-02 15:10 +0000
                                        Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-02 11:16 -0800
                                          Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-07 15:14 +0000
                                  Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-01 21:45 +0100
                                    Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-01 13:07 -0800
                                      Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-01 23:44 +0100
                                        Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-01 18:22 -0800
                                          Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-02 23:09 +0100
                                            Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-03 01:47 +0100
                                          Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-04 10:34 +0000
                                            Re: Comparing arraies Dr J R Stockton <reply1205@merlyn.demon.co.uk> - 2012-02-05 16:47 +0000
                                              Re: Comparing arraies John G Harris <john@nospam.demon.co.uk> - 2012-02-06 15:21 +0000
                                            Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-02-04 23:37 -0800
      Re: Comparing arraies Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-26 23:08 +0000
        Re: Comparing arraies Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-27 01:42 +0000
          Re: Comparing arraies Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-27 11:41 +0100
        Re: Comparing arraies Gene Wirchenko <genew@ocis.net> - 2012-01-26 16:24 -0800
          Re: Comparing arraies "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-27 08:50 +0000
        Re: Comparing arraies Dr J R Stockton <reply1204@merlyn.demon.co.uk> - 2012-01-27 21:07 +0000
          Re: Comparing arraies "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-28 13:45 +0000
    Re: Comparing arraies "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-26 16:21 -0800
      Re: Comparing arraies Martin Honnen <mahotrash@yahoo.de> - 2012-01-27 16:00 +0100

Page 3 of 3 — ← Prev page 1 2 [3]


#10665

From"Evertjan." <exjxw.hannivoort@interxnl.net>
Date2012-01-28 13:45 +0000
Message-ID<Xns9FE89621C4B12eejj99@194.109.133.133>
In reply to#10659
Dr J R Stockton wrote on 27 jan 2012 in comp.lang.javascript:

> Observe :
>         A = new Array(5)
>         B = new Array(6)
> for which A[<anything>] = B[<anything>] = undefined; yet String(B) is
> visibly longer than String(A).
> 

Only longer, 
if you uphold the for javascript clearly wrong dogma,
that an array must be integer continuous from it's bottom to it's top 
index.

I would say both arrays are just as short, 
having no visible or invisible content.

arr.length just is a sort of missnomer for the read/write value of the 
theoretical top index, also wrongly assuming the defined bottom index is 
always 0.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#10618

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2012-01-26 16:21 -0800
Message-ID<a58dd870-e304-4c09-9ad9-4565bb9b627c@h12g2000yqg.googlegroups.com>
In reply to#10604
On Jan 26, 9:23 am, Archos <raul....@sent.com> wrote:
> How to know if 2 arraies are equal? I was expecting that it could be
> checked so:
>
> >>> var array1 = [1,2,3,4], array2 = [1,2,3,4];
> >>> if (array1 === array2) { console.log("array1 and array2 are equal"); }
>
> Since the comparing of strings or integers works:
>
> var a = "2", b = "2";
> if (a === b) { console.log("a == b"); }


Two arrays are equal iff they have equal elements in respective
positions:

var a1 = [1,2,3,4], a2 = [1,2,3,4];

a1.every(function(e,i){ return e === a2[i]}); //true

a1 = a2 = [1, 2, 3, 4];

a1.every(function(e,i){ return e === a2[i]}); //true

var o = {foo: 'bar'}, o2 = {bar: 'baz'};

a1 = [o,o2], a2 = [o2,o];

a1.every(function(e,i){ return e === a2[i]}); //false

a1 = [o,o2], a2 = [o,o2];

a1.every(function(e,i){ return e === a2[i]}); //true

[toc] | [prev] | [next] | [standalone]


#10644

FromMartin Honnen <mahotrash@yahoo.de>
Date2012-01-27 16:00 +0100
Message-ID<4f22bc02$0$6583$9b4e6d93@newsspool3.arcor-online.net>
In reply to#10618
Michael Haufe (TNO) wrote:
> On Jan 26, 9:23 am, Archos<raul....@sent.com>  wrote:
>> How to know if 2 arraies are equal? I was expecting that it could be
>> checked so:
>>
>>>>> var array1 = [1,2,3,4], array2 = [1,2,3,4];
>>>>> if (array1 === array2) { console.log("array1 and array2 are equal"); }
>>

> Two arrays are equal iff they have equal elements in respective
> positions:
>
> var a1 = [1,2,3,4], a2 = [1,2,3,4];
>
> a1.every(function(e,i){ return e === a2[i]}); //true

I think an additional check that the length of both arrays is the same 
is necessary as otherwise solely doing
  a1.every(function(e,i){ return e === a2[i]});
with a1 being shorter than a2 might give true for e.g.
  a1 = [1, 2, 3];
  a2 = [1, 2, 3, 4, 5];
which is likely not intended.


-- 

	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

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


csiph-web