Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
In JS you can perform following operations on Arrays:
const [ a, b, c ] = [ 1, 2, 3 ]
which corresponds to mutli-assignment in Groovy.
However JS does some really nice syntactic sugar with Object deconstruction on top:
// "forward" const object = { question:'about life', answer:42, z:11 } const { question, answer } = object // "backward" const newObject = { question, answer }
This way you can save a lot of code-duplication between declaring variables and Map keys.
The syntax could look like:
// "forward" def object = [ question:'about life', answer:42, z:11 ] def ( question, answer ) = object // "backward" def newObject = [ :question, answer: ]
What do you think?