So, you want to write code like the pros? I’m going to outline the exact habits that have helped me, a professional software developer at Google, since I began my career in 2006.
The first thing you should do is always indent your code. This will make it much easier to read and understand. Spaces are preferred over tabs, but it’s up to you.
The second thing you should do is always use semicolons. This will prevent ASI from happening and cause bugs due to some unclear edge cases.
The third thing you should do is always use curly braces for if-else statements even though they are optional because it will make your code easier to navigate and understand for other people who may or may not be as intelligent as you are.
The fourth thing you should do is always use loops instead of recursion because recursion takes up too much memory and can cause stack overflows in large inputs that may or may not occur depending on your algorithm and input size (which could be anything).
The fifth thing you should do is always use while loops instead of for loops because while loops are more efficient than for loops in most cases where efficiency matters (which could be anything).
The sixth thing you should do is always use === instead of
The linter is a tool that analyzes your code and looks for mistakes. It is much like a spell checker. It will not correct your mistakes for you, but it will point them out and give you some suggestions on how to fix them.
Report Cyclomatic complexity Unused variables Undeclared variables.
It is open source and will always stay this way. Please feel free to report any bugs, feature requests or other issues.
The easiest way to use JSHint is through our web-based interface at jshint.com. Just copy and paste your code into the box below and click “JSHint”.
If you are using Node, you can install a command line version of JSHint called jshint-cli. To do so, run npm install -g jshint-cli.
Once installed, invoke it like so: $ jshint myfile.js
JSHint will then print out any possible issues with the code onto your console. If no errors were found, then a success message will be printed out on the console.
Some of the reasons for this are:
JSHint was created by Anton Kovalyov (aka valueof), who later handed the project to Mike Sherov (aka msherov).
JSHint is currently maintained and developed by Anton Kovalyov, Mike Sherov, and other contributors.
If you think you’ve found a bug in JSHint, please open an issue on GitHub. If you have a patch, please feel free to send us a pull request.