4 ms·
As a JS hater, I have to admit it was a pleasant read. I would still love a "20 mistakes you need to avoid when writing JS". One of the most horrible "WHAT IS
by jokoon 5y ago
As a JS hater, I have to admit it was a pleasant read.
I would still love a "20 mistakes you need to avoid when writing JS".
One of the most horrible "WHAT IS HAPPENING HERE?" moment in JS was when there was a missing semicolon after some multiline code and error messages were not helping at all. I'm wondering if JS compilers will have some linter or will one day help beginners be warned of "possible mistakes".
Isn't there a list of "good practices" or "js coding standards"?
- hnarn 5y ago> a missing semicolon after some multiline code I'm not a JS dev but isn't this something almost any IDE with a linter would help you out with?
- z3t4 5y agoBecause errors dude to missing semicolon will happen so rarely, people skip them for various reasons, but the fix for these errors are to use semicolon, or a tool that will tell you where a semicolon would change the "abstract syntax tree" (AST). Because the JS ecosystem is so diverse, there are many "best practices". And the languages itself has many, many ways to do the same thing, espcially with ES6/2015 onward you have many more options, which are mostly picked by personal preferences and synthetic reasons.
- mostlystatic 5y agoFormatters like Prettier can help here. For example, this code contains a function call, because the first line doesn't end with a semicolon. let a = 123 ({a}= {a: 10}) Prettier will reformat it like this: let a = 123(({ a } = { a: 10 })); You could also use ESLint to enforce semicolons. The error messages when running code like this aren't very good though.