Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping values/splats in destructuring #86

Closed
zmthy opened this issue Jan 12, 2010 · 1 comment
Closed

Skipping values/splats in destructuring #86

zmthy opened this issue Jan 12, 2010 · 1 comment

Comments

@zmthy
Copy link
Collaborator

zmthy commented Jan 12, 2010

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
Copy link
Owner

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...

protez pushed a commit to protez/coffee-script that referenced this issue Jul 28, 2015
Thanks @davidbau for the bug report.  Bump to version 1.6.3-g
as a result.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants