1. The semicolon is used to avoid unexpected errors such as the following: line 2 f is parsed to line 3 (a + b) as a function:
let a = 3, b = 4, x = 5, f = 6;
let y = x + f
(a + b).toString()Copy the code
2. Developers or compilers can safely compress code by removing excess whitespace;
3. Adding semicolons can improve code performance in some cases because it saves the parser the extra time to calculate where to insert semicolons.
Code door: wx.zsxq.com/dweb2/index… .