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


Groups > comp.lang.javascript > #12260

Re: Empty array

From Dr J R Stockton <reply1209@merlyn.demon.co.uk>
Newsgroups comp.lang.javascript
Subject Re: Empty array
Date 2012-02-28 22:00 +0000
Organization Home
Message-ID <CESvYCJ95UTPFw+M@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <0f481e7c-97b9-4c76-9660-321681876658@w9g2000vbv.googlegroups.com> <e8bddc62-6b7f-4463-b0bb-51912eeca4ef@z31g2000vbt.googlegroups.com>

Show all headers | View raw


In comp.lang.javascript message <e8bddc62-6b7f-4463-b0bb-51912eeca4ef@z3
1g2000vbt.googlegroups.com>, Mon, 27 Feb 2012 07:30:02, Asen Bozhilov
<asen.bozhilov@gmail.com> posted:

>Archos wrote:
>> Is there any way to know if an array is empty? Without using its
>> length method?
>
>The array is applicable when you need sequenced collection. In
>sequenced collection the `lenght' property is sufficed to check for
>emptiness.

Only if the indexes are all in the range from zero to some non-negative
integer.

A = [] ;                                // empty array
A[undefined] = NaN ;                    // non-empty array
for (J in A) alert(J + " " + A[J]) ;    // one alert :   undefined NaN
alert(A.length) ;                       // shows a zero

-- 
 (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk  BP7, Delphi 3 & 2006.
   <http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
   <http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
   NOT <http://support.codegear.com/newsgroups/>: news:borland.* Guidelines

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


Thread

Empty array Archos <raul.san@sent.com> - 2012-02-25 10:21 -0800
  Re: Empty array Gregor Kofler <usenet@gregorkofler.com> - 2012-02-25 23:02 +0100
  Re: Empty array Dr J R Stockton <reply1208@merlyn.demon.co.uk> - 2012-02-26 20:50 +0000
    Re: Empty array "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-27 14:46 +0000
      Re: Empty array Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-02-28 23:42 +0000
  Re: Empty array Asen Bozhilov <asen.bozhilov@gmail.com> - 2012-02-27 07:30 -0800
    Re: Empty array Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-02-28 22:00 +0000
      Re: Empty array Gene Wirchenko <genew@ocis.net> - 2012-02-28 17:20 -0800
        Re: Empty array Asen Bozhilov <asen.bozhilov@gmail.com> - 2012-02-29 01:23 -0800
          Re: Empty array Gene Wirchenko <genew@ocis.net> - 2012-02-29 14:12 -0800
        Re: Empty array Dr J R Stockton <reply1209@merlyn.demon.co.uk> - 2012-03-01 21:20 +0000

csiph-web