Skipping values/splats in destructuring
Closed this issue · 1 comments
zmthy commented
Any takers for the Javascript 1.7 syntax of skipping values?
[a,, b] = [x, y, z]
is roughly
__a = [x, y, z]
a = __a[0]
b = __a[2]
Also, how about splats?
[a, b...] = [x, y, z]
to
__a = [x, y, z]
a = __a[0]
b = Array.prototype.slice.call(__a, 1)
jashkenas commented
Nice idea. Splats are now allowed in destructuring assignment.
[a, b...]: [1, 2, 3]
Compiles into this:
var __a, a, b;
__a = [1, 2, 3];
a = __a[0];
b = Array.prototype.slice.call(__a, 1);
b
becomes [2, 3]
Not adding the skipping-values-with-commas. It's too typo-prone and funky-looking. Closing the ticket...