The problem of variable structure assignment and let in ES6

let x;
{x} = {x: 1};

Why is this reported wrong?

May.07,2021

x has been defined as undefined


the above code will be misspelled because the JavaScript engine interprets {x} as a block of code, resulting in a syntax error. This problem can only be solved by not writing curly braces at the beginning of the line and preventing JavaScript from interpreting it as a code block. reference

    // 
    let x;
    ({x} = {x: 1});

from teacher Ruan Yifeng's explanation of "introduction to ES6 Standards" the code writing on page 23
will report an error because the js engine will interpret {x} as a code block, resulting in a syntax error. This problem can be solved only if does not write curly braces at the beginning of the line, preventing js from interpreting it as a code block.

({x} = {x: 1}) 

that's fine

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b420a0-2c5f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b420a0-2c5f3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?