You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • 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/Dest­ructuring_assignment)

    For example, this doesn't work:

    const someObject = { a: 1, b: 2 }
    const { a, b } = someObject; // syntax errors on this line
    const a = someObject.a; // ...but this does work
    

    Similarly, this doesn't work:

    const a = 1, b = 2;
    const someObject = { a, b }; // syntax errors here
    someObject.a = a; // ... but this works
    

    Any plans to support these styles of operations?

  • 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

    http://www.espruino.com/Features



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

About

Avatar for Robin @Robin started