It’s not a semicolon problem, but if there is no blocking of ; sign, the interpreter directly merges the two statements into:
var xx = function(){}[1,2,3].aa(22);
Pay special attention when using statements starting with () and [], because these two operators will be combined with the previous expression first, and the ; sign cannot be omitted
In some cases; sign is not necessary, such as;
var a = 1, b=2
a++
b++
This will not report an error
Since js does not clearly explain such behavior, and the page is easy to be confused, the recommended approach is generally: Whether it is necessary or not, you'd better add a sentence at the end of the ";" separator, unless you Know exactly what the result is (want). This is called best practice
It’s not a semicolon problem,
but if there is no blocking of ; sign, the interpreter directly merges the two statements into:
Pay special attention when using statements starting with () and [], because these two operators will be combined with the previous expression first, and the ; sign cannot be omitted
In some cases; sign is not necessary, such as;
This will not report an error
Since js does not clearly explain such behavior, and the page is easy to be confused, the recommended approach is generally:
Whether it is necessary or not, you'd better add a sentence at the end of the ";" separator, unless you Know exactly what the result is (want).
This is called best practice
function(){}[1,2,3] returns undefined
The semicolon here should indicate the end of this statement, right?
I think you can tell it when you write it like this.