array slice syntax

Lars T Hansen lth at acm.org
Thu Aug 16 10:42:47 PDT 2007


On 8/16/07, Stefan Gössner <stefan at goessner.net> wrote:
> Hello,
> here are my first questions after following the list quite a while.
>
> 1. I really like the array slice syntax [start:end:step] described in
> http://developer.mozilla.org/es4/proposals/slice_syntax.html
>
> The description seems to miss the case, where 'start' is greater than 'end'.
>
> a[5:2]
>
> Will
> (a) 'step' be implicitely set to -1 ?
> (b) an empty array come as result ?
> (c) an error occur ?

The description seems to be clear here, the result should be an empty array.

> 2. The descendant operator '..' is mentioned only in the tutorial
> introduction.
> http://developer.mozilla.org/es4/spec/chapter_1_tutorial_introduction.html
> I could not find it mentioned elsewhere.
>
> Is it also considered to work with array notation as in:
>
> y..[0]   // access the first element of all arrays of 'y' and it's
> descendants.

I don't think so.  The descendant operator is for E4X (ECMAScript for
XML, ECMA-357) and has not been discussed in other contexts.  E4X is
not included in ECMAScript 4 at this stage.

--lars



More information about the Es4-discuss mailing list