3 ms·
> Ending all your lines with semi-colons won't save you, only understanding ASI will do that. It will save you if you use JSLint/JSHint/ESLint/etc. In your ex
by dugword 11y ago
> Ending all your lines with semi-colons won't save you, only understanding ASI will do that.
It will save you if you use JSLint/JSHint/ESLint/etc.
In your example you will get an error about a semicolon missing after the return statement.
If your convention is to always use semicolons your editor can let you know you have made a mistake. If you don't use semicolons then you have to turn off these warnings from your Linter and you won't catch the error until you see weird results at runtime.
And that's the purposing of always using semicolons, so you can have automated tools help you.
- bilalq 11y agoSure, a linter can handle that situation. But linters can handle the semicolon-free style just as well[1]. There is no real value-add from semicolons; they're just a matter of stylistic preference. [1]: https://github.com/feross/standard https://github.com/feross/standard