Reputation: 16521
I've been using and loving babel (6.5.2) for a while now and find the new destructuring syntax great for writing clearer JavaScript.
Why doesn't the rest destructuring work (it generates a token error) anywhere in the array? For example:
const [column, ...restOfColumns] = columns;
const objProps = column.valueChain.slice(0, -1);
const prop = column.valueChain[column.valueChain.length - 1];
//const [...objProps, prop] = column.valueChain
The commented out line would replace the preceding two lines with something much easier to read and understand.
Upvotes: 1
Views: 114
Reputation: 2948
The simple answer is that when you use the destructing syntax ...
, it means everything else. Therefore when you try [...objProps, prop]
, it doesn't know what to assign to prop
as you have assigned all values already to objProps
Upvotes: 4