-
• #2
Sat 2021.01.30
Hi @JosiahBryan,
'destructuring assignment and composition is not supported in Espurino'
That would be correct according to this reference beneath table ES6
From the MDN link in post#1'The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.'
Were you after the exact Destruturing syntax shown in post #1, or would a similar JSON object notation work for the task at hand? ref: properties from objects
const someObject = { 'a': 1, 'b': 2 }; const a = someObject.a; console.log ( "Value a: " + a ); // output >Value a: 1
Note that use of
dump()
will show the same as:const someObject = { a: 1, b: 2 }; const a = someObject.a; console.log ( "Value a: " + a ); // output >Value a: 1
re: 'Any plans to support these styles of operations?'
We'll need to defer to @Gordon for the official plan. . . .
-
• #3
Yes, you're right - there's no support at the moment. Generally the state of language support is on the http://www.espruino.com/Features page as Robin says.
However nothing stops you from transpiling your JS code into something else. For instance if you go to
Minification
in settings and turn it toClosure (online) - Simple Optimisations
you can then use destructuring.There's a wishlist here which you can vote on: https://github.com/espruino/Espruino/issues/1302
And generally I do try and add the most requested features when I get time :)
Hey guys!
It seems that destructuring assignment and composition is not supported in Espurino...is that true? Or is there a way to enable it? (Destruturing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)
For example, this doesn't work:
Similarly, this doesn't work:
Any plans to support these styles of operations?