Make Your Code Easy To Understand
Pay Attention To Details
You’d be surprised how many hours beginners spend hunting down an error, only to realize that the they forgot a semicolon or they simply forgot the var tag when declaring a variable! Another common mistake is omitting curly braces after statements like if, else, while and for. Although it is allowed, it can still cause quite a few bugs down the road, so make it a habit to always surround blocks of code with curly braces.
Linting Is Your Friend
Lint checkers can be used to hunt down typos, errors and other little bugs, and the most popular ones are JSHint, JSLint, and Closure Linter, which might not sound like too big of a deal, but once you’re buried under hundreds and thousands of line of code, even a single typo can make your life a living nightmare, which is why these checkers can come in really handy.