Why is a semicolon needed here? [duplicate]
问题 This question already has an answer here : Destructuring assignment in while loop in ES6 function doesn't propogate out of loop? (1 answer) Closed 4 years ago . I am simply using es6 to reassign variables a & b. Why do I get an error if I leave the semicolon off of the a and b declaration and assignment statements? Does the parser try to pull a property out of 2 if the semicolon is left off? let b = 2[a, b]...? Works: let a = 1; let b = 2; [a, b] = [b, a] Error: let a = 1 let b = 2 [a, b] =