Problem Description:
The structure of the function is as shown in the browser error when invoking the function:
Analysis Reason:
In JS syntax, if a statement is exclusive to a line, you can usually omit the semicolon at the end of the sentence
But in fact, when the JS parsing code, only in the end of the sentence is missing a semicolon will not work properly, will automatically fill the semicolon
If the statements in front and back can form a syntactically correct statement, the semicolon is not automatically filled
In the above function, JS actually handles the code as:
function Test (A, B, c) { var x = A + b[a, B, C].foreach (function (e) { // ) . .. })}
In general, if the statement begins with "(", "[", "/", "+", "-" , the statement is most likely resolved with the previous statement
However, if the statement starts with "+ +" or "--", it takes precedence as the prefix operator for parsing
The statement will be parsed to x; ++y instead of + x; y
In addition, if the statement ends with return, continue, and break, JS will automatically fill the semicolon at the newline.
Solution:
Add a semicolon manually at the end of a statement