I'm still learning too, so I don't fully understand this, but it is an example of a situation where automatic semicolon insertion doesn't work the way you might expect. If you try
var a = 3
var b = 7;
[a, b] = [b, a]
you should find that you get the expected result. The following also works:
var a = 3
var b = 7
{
[a, b] = [b, a]
}
console.log(a) // expect 7
console.log(b) // expect 3
However, without a semicolon after the 7, or the enclosing braces, it is somehow interpreted as
var a = 3
var b = [b, a]
console.log(a) // expect 3
console.log(b) // expect [undefined, 3]
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Anya,
I'm still learning too, so I don't fully understand this, but it is an example of a situation where automatic semicolon insertion doesn't work the way you might expect. If you try
you should find that you get the expected result. The following also works:
However, without a semicolon after the 7, or the enclosing braces, it is somehow interpreted as