It is entirely up to your personal habits to add and not add semicolons, but it is recommended to use semicolons for code stability (parsing errors).
JavaScript auto-semicolon rule:
1. When there are newline characters (including multiline comments with line breaks), and the next token cannot match the previous syntax, the semicolon is automatically complement.
2. When there is a semicolon is missing, a semicolon is complement.
3. When the program source code ends, if a semicolon is missing, the semicolon will be complement.
Conclusion:
1. In return, break, continue, post-increment, and post-decrement five statements, line breaks can completely replace the role of semicolons.
The 2.var if do and for continue break return with switch throw try debugger statements beginning with several keywords, as well as empty statements, with no effect on the previous line plus no semicolons.
3. In the case of expression statements and function expression statements, it is very dangerous to follow the semicolon without semicolons, which is extremely complex.
4. where (and [at the beginning of the statement, the front without semicolons is extremely dangerous.
Should I add a semicolon after a JavaScript statement?