On Wed, May 12, 2010 at 3:12 AM, Dmitry A. Soshnikov
<[email protected]> wrote:
> a[2:5] # slice

This reminds me lack of a Range operator in javascript.
The one like in Pascal and PL/SQL
http://www.techonthenet.com/oracle/loops/for_loop.php
Which can also be used in for loop

Many times when coding I need something like that in Javascript too
And I suggest ... (three dots) as the operator because : has other
uses in javascript and .. is used by E4X

Example usage are.

    startIndex = 2;
    lastIndex = 5;
    myRange = startIndex ... lastIndex;
    a[myRange]  // array slice

instead of
   if(a >= 2 && a <= 5) doSomething();

we could simplify code as
   if(a in 2 ... 5) doSomething();

or
  for(i in 2 ... 5) print(i);

we should also allow usage for Sting and Date range checking, like
    if('Dmitry' in 'Biju' ... 'Jordan') doSomething();
and
    if( (new Date(2010,1,1)) in (new Date(2008,1,1)) ... (new
Date(2012,1,1))) doSomething();
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to