-
Notifications
You must be signed in to change notification settings - Fork 6
Assignment Destructuring
Shane Brinkman-Davis Delamore edited this page Mar 24, 2019
·
3 revisions
See Destructuring for an overview. See also: Extract-Destructuring, Structuring and Restructuring
CaffeineScript fully supports JavaScript destructuring syntax and semantics with one important difference. Ellipsis (...) comes after, not before. This is CoffeeScript-style as well as common English usage.
Examples
[a, b] = [10, 20]
# a == 10, b == 20
[a, b, rest...] = 10, 20, 30, 40, 50
# a == 10, b == 20, c == 30, 40, 50
{a, b} = a: 10, b: 20
# a == 10, b == 20NOTE: CoffeeScript destructuring features which are not supported by JavaScript, e.g. an ellipsis on a non-last array element: [a..., b] = c, are not supported in CaffeineScript either... yet.
- Home
- Get Started
- Benefits
- Highlights
- Productivity by Design
- CaffeineScript Design
- What is CaffeineScript Good For?
- Get the most out of JavaScript
- Language Comparison
- CHANGELOG
- Blocks Instead of Brackets
- Binary Line-Starts
- Everything Returns a Value
- Streamlined Modules
- Scopes and Variables
- Optional Commas
- Semantics
- Ambiguities