Strawman: Complete array and object destructuring

2017-03-28 Thread Paul Whipp
The ... destructuring for arrays is an excellent improvement that makes javascript code more readable and robust. On seeing the syntax for the first time I expected to be able to use it more completely. For example: ```js const [column, ...restOfColumns] = columns; const objProps = column.valueCh

Re: Strawman: Complete array and object destructuring

2017-03-28 Thread Jordan Harband
The reason this doesn't work is because `...` in this context is not array destructuring - it's *iterable* destructuring. When you spread a string, you don't get each code unit, you get each code *point* - and similarly, you can spread any iterator, array or not, and collect items from it Iterator

Re: Strawman: Complete array and object destructuring

2017-03-28 Thread Paul Whipp
Thanks Jordan, as you describe iterable destructuring, it makes implementation sense. The square brackets (and documentation eg: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) had me thinking of it as destructuring into an array and then mappi