I was arguing that non-strict destructuring is bad, so this code IMHO should throw exception:
a,b,c=[1,2,3,4]
The reason for this is - if you assume array has 3 elements, but it has more, your code will silently ignore the rest. You'll have to write your assertion every time you destructure, to be sure that destructuring don't ignore data. The exceptional case IMHO is when you need to ignore data, and so code for this case should be uglier, not the other way around. You are right that catching exception for regular code path isn't the best way, but at least programmer intention is clear then.
You could also do
a,b,c = list.slice(0,3);
which copies the array, but at least it's clear what it assumes about the array. And it can be easily modified to get last 3 values, or 3 values from the middle of list. So no need for 2 idioms depending on which items you want to get from the array.
You could also do
which copies the array, but at least it's clear what it assumes about the array. And it can be easily modified to get last 3 values, or 3 values from the middle of list. So no need for 2 idioms depending on which items you want to get from the array.