3 ms·
I never used semicolons and I have never had a problem. Just avoid ambiguous code.
by 58028641 11y ago
I never used semicolons and I have never had a problem. Just avoid ambiguous code.
- Cthulhu_ 11y agoI have a short anecdote where not using semicolons caused problems. Or well, not even in our code. We were using (IIRC) a version of underscore.js that did not use or did not end the final line thing (probably one of them self-executing functions) with a semicolon. Because of reasons, our application would break in production builds; the lack of semicolons would, in some cases, cause an issue after concatenating that file with another vendor's file. A very obscure and hard to track one, too - it took us weeks if not months to find it.
- rhinoceraptor 11y agoThat's why you sometimes see library code wrapped in IIFEs, starting with a semicolon, like so: ;(function () { // Library here }());
- gpvos 11y agoI've seen recommendations to start an included Javascript file with a semicolon to avoid this problem.
- fengb 11y agoJust concat using a semicolon instead of just a new line.
- christophilus 11y agoYeah. I haven't run into these sorts of problems since using a bundler that doesn't just do plain file concatenation (Webpack, Browserify, etc). I think that if you write clear, unambiguous code, and use ES6 modules via Webpack, you can (fairly) safely drop semicolons.