Es6 uses a declared variable to deconstruct an assignment

let x;
{x} = {x: 1};
// SyntaxError: syntax error

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.

do not understand the meaning of the above sentence, why {x} can be understood as a code block will have syntax errors, why not declare variables in advance will not report errors

Sep.11,2021

wrap it in parentheses

clipboard.png


this is a deconstruction assignment:

let x;
{x} = {x: 1}; //x{x}
< hr >

or you can also understand it this way:
= is the assignment operator, which is combined from right to left. (note that the = in js can actually be understood as < = , such as the statement x = axi3; is assigning a value to x), after apl3, which requires that the Operand on the left is a variable, an element of an array, or an attribute of an object, which requires that the Operand on the left is a variable, an element of an array, or an attribute of an object. So you put a code block on the left, which is obviously not appropriate.

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-1e46682-43161.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-1e46682-43161.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?