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


Groups > comp.lang.javascript > #8160

Re: Fun with Arrays: What Have I Done?

From RobG <rgqld@iinet.net.au>
Newsgroups comp.lang.javascript
Subject Re: Fun with Arrays: What Have I Done?
Date 2011-11-08 21:44 -0800
Organization http://groups.google.com
Message-ID <f0172f78-ea70-445c-b71e-0077d80a0fcd@m26g2000prn.googlegroups.com> (permalink)
References <d40kb79urtc6ekdiubqajt8piarusksvro@4ax.com> <cbd20c37-234b-4bf5-acfc-658d3e5d4811@q39g2000prg.googlegroups.com>

Show all headers | View raw


On Nov 9, 3:30 pm, RobG <rg...@iinet.net.au> wrote:
[...]
> The length property is always one greater than the largest positive
> integer index

That should be "... is always *at least* one greater ..." since the
length can be set to any positive integer number (within the limits of
0 to 2^32 - 1).

Setting length higher than the highest index just increases the value
of 'length', it doesn't create any extra properties. Setting it
shorter truncates the array so the highest index is now one less than
length and any elements with names equal to or greater than length are
discarded.

See ECMA-262 § 15.4.


--
Rob

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


Thread

Fun with Arrays: What Have I Done? Gene Wirchenko <genew@ocis.net> - 2011-11-08 20:32 -0800
  Re: Fun with Arrays: What Have I Done? RobG <rgqld@iinet.net.au> - 2011-11-08 21:30 -0800
    Re: Fun with Arrays: What Have I Done? RobG <rgqld@iinet.net.au> - 2011-11-08 21:44 -0800
    Re: Fun with Arrays: What Have I Done? Dr J R Stockton <reply1145@merlyn.demon.co.uk> - 2011-11-10 20:01 +0000
  Re: Fun with Arrays: What Have I Done? Tim Streater <timstreater@greenbee.net> - 2011-11-09 10:57 +0000
    Re: Fun with Arrays: What Have I Done? SteveYoungTbird <stephen.young@chello.at> - 2011-11-09 12:17 +0100
    Re: Fun with Arrays: What Have I Done? Elegie <elegie@anonymous.invalid> - 2011-11-09 12:24 +0100
      Re: Fun with Arrays: What Have I Done? Tim Streater <timstreater@greenbee.net> - 2011-11-09 13:31 +0000
    Re: Fun with Arrays: What Have I Done? Gene Wirchenko <genew@ocis.net> - 2011-11-09 10:32 -0800

csiph-web