Best developer practices run the gamut from keeping the cruft out of your code to ensuring your code is accessible to all your application or site’s users. In this chapter, I’m focusing on two specific components: prelimary testing and accessibility.
There are various forms of testing, including running tools that highlight bad practices, unit testing, performance testing, as well as testing your applications in a variety of environments.
Regardless of how well the code tests out, if it isn’t accessible to all your audience, then it fails. At the end of the chapter, we’ll look at a couple of approaches you can take to ensure your code is accessible as well as accurate and efficient.
You want to check your code for any gotchas that may not trigger a failure, but also aren’t the best coding practices.
Use a lint tool such as JSHint to highlight potential problems or less than optimal code.
The simplest approach to ensuring your code meets a minimum standard of acceptable coding standards is to use the strict setting at the beginning of your code or function:
This setting ensures certain programming standards are met, such as always defining variables, and never using
eval(). And of course, the most reliable way of ensuring your code meets standards is whatever error mechanism is built into the tools you’re using to run the code, typically explored in depth using your favorite ...