I know there is already a similar question as below, but I still have a question about ES6.
Why is a semicolon needed here?
As you see the website as below,
http://es6-features.org/#ArrayMatching
This code should work, but it causes that a and b are all undefined.
var list = [ 1, 2, 3 ]
var [ a, , b ] = list
[ b, a ] = [ a, b ]
The only way I found to fix it was by putting a semicolon on line 2
var list = [ 1, 2, 3 ]
var [ a, , b ] = list;
[ b, a ] = [ a, b ]
Isn't ES6 supposed to work without any semicolon? (I haven't used any semicolon in my javascript code so far, but now I am kind of lost. Should I just put a semicolon only when it is needed, or put a semicolon on every statement?)
Are there any other cases that I have to put a semicolon?