Siegfried Ehret (2017-08-02T11:42:14.000Z)
Thanks a lot.

I was not sure if this this would be related to rest operator of to
destructuring...And I wasn't well aware of «The reason this doesn't work is because ...
in this context is not array destructuring - it's *iterable*
destructuring.»
I would love to read a reply to the last message (from Isiah in this
thread:
https://esdiscuss.org/topic/strawman-complete-array-and-object-destructuring)
--
  Siegfried Ehret
  siegfried at ehret.me
  +33 (0) 6 22 68 17 44



On Wed, Aug 2, 2017, at 12:54 PM, T.J. Crowder wrote:
> Previous disussions:
> 
> https://esdiscuss.org/topic/strawman-complete-array-and-object-destructuring> 
> https://esdiscuss.org/topic/rest-parameters
> 
> -- T.J. Crowder
> 
> On Wed, Aug 2, 2017 at 10:58 AM, Siegfried Ehret
> <siegfried at ehret.me> wrote:>> Hello,
>> 
>>  This is a small idea I had recently: to update the rest operator
>>  to make>>  it work not only to get the last elements.
>> 
>>  As an example, we already have:
>> 
>>  ```javascript
>>  const myArray = [1, 2, 3, 4, 5, ..., 99, 100];
>>  [first, second, ...rest] = myArray;
>> 
>>  // first = 1
>>  // second = 2
>>  // rest = [3, 4, 5, ..., 99, 100]
>>  ```
>> 
>>  It would be interesting to have:
>> 
>>  ```javascript
>>  [...rest, previous, last] = myArray;
>> 
>>  // rest = [1, 2, 3, ..., 97, 98]
>>  // previous = 99
>>  // last = 100
>>  ```
>> 
>>  And:
>> 
>>  ```javascript
>>  [first, ...rest, last] = myArray;
>> 
>>  // first = 1
>>  // rest = [2, 3, ..., 97, 98, 99]
>>  // last = 100
>>  ```
>> 
>>  Another use case: inside a variadic function to separate the
>>  callback>>  (often the last argument) and the function parameters.
>> 
>>  I asked myself «why would I want the last elements of an array»,
>>  and my>>  answer was «for the same reason which motivates me to get the first>>  ones».
>> 
>>  What do you think ?
>>
>>  --
>>    Siegfried Ehret siegfried at ehret.me +33 (0) 6 22 68 17 44[1]
>>  _______________________________________________
>>  es-discuss mailing list es-discuss at mozilla.org
>>  https://mail.mozilla.org/listinfo/es-discuss> 


Links:

  1. tel:%2B33%20%280%29%206%2022%2068%2017%2044
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170802/16d3c929/attachment.html>
siegfried at ehret.me (2017-08-02T11:46:02.827Z)
Thanks a lot.

I was not sure if this this would be related to rest operator of to
destructuring...

And I wasn't well aware of «The reason this doesn't work is because ...
in this context is not array destructuring - it's *iterable*
destructuring.»

I would love to read a reply to the last message (from Isiah in this
thread:
https://esdiscuss.org/topic/strawman-complete-array-and-object-destructuring)

--
Siegfried Ehret
siegfried at ehret.me (2017-08-02T11:45:08.155Z)
Thanks a lot.

I was not sure if this this would be related to rest operator of to
destructuring...And I wasn't well aware of «The reason this doesn't work is because ...
in this context is not array destructuring - it's *iterable*
destructuring.»
I would love to read a reply to the last message (from Isiah in this
thread:
https://esdiscuss.org/topic/strawman-complete-array-and-object-destructuring)

--
  Siegfried Ehret
  siegfried at ehret.me
siegfried at ehret.me (2017-08-02T11:44:55.729Z)
Thanks a lot.

I was not sure if this this would be related to rest operator of to
destructuring...And I wasn't well aware of «The reason this doesn't work is because ...
in this context is not array destructuring - it's *iterable*
destructuring.»
I would love to read a reply to the last message (from Isiah in this
thread:
https://esdiscuss.org/topic/strawman-complete-array-and-object-destructuring)

--
  Siegfried Ehret
  siegfried at ehret.me
  +33 (0) 6 22 68 17 44



On Wed, Aug 2, 2017, at 12:54 PM, T.J. Crowder wrote:
> Previous disussions:
> 
> https://esdiscuss.org/topic/strawman-complete-array-and-object-destructuring> 
> https://esdiscuss.org/topic/rest-parameters
> 
> -- T.J. Crowder
> 
> On Wed, Aug 2, 2017 at 10:58 AM, Siegfried Ehret
> <siegfried at ehret.me> wrote:>> Hello,
>> 
>>  This is a small idea I had recently: to update the rest operator
>>  to make>>  it work not only to get the last elements.
>> 
>>  As an example, we already have:
>> 
>>  ```javascript
>>  const myArray = [1, 2, 3, 4, 5, ..., 99, 100];
>>  [first, second, ...rest] = myArray;
>> 
>>  // first = 1
>>  // second = 2
>>  // rest = [3, 4, 5, ..., 99, 100]
>>  ```
>> 
>>  It would be interesting to have:
>> 
>>  ```javascript
>>  [...rest, previous, last] = myArray;
>> 
>>  // rest = [1, 2, 3, ..., 97, 98]
>>  // previous = 99
>>  // last = 100
>>  ```
>> 
>>  And:
>> 
>>  ```javascript
>>  [first, ...rest, last] = myArray;
>> 
>>  // first = 1
>>  // rest = [2, 3, ..., 97, 98, 99]
>>  // last = 100
>>  ```
>> 
>>  Another use case: inside a variadic function to separate the
>>  callback>>  (often the last argument) and the function parameters.
>> 
>>  I asked myself «why would I want the last elements of an array»,
>>  and my>>  answer was «for the same reason which motivates me to get the first>>  ones».
>> 
>>  What do you think ?
>>
>>  --
>>    Siegfried Ehret siegfried at ehret.me +33 (0) 6 22 68 17 44[1]
>>  _______________________________________________
>>  es-discuss mailing list es-discuss at mozilla.org
>>  https://mail.mozilla.org/listinfo/es-discuss> 


Links:

  1. tel:%2B33%20%280%29%206%2022%2068%2017%2044