- Maintain your JSDoc comments. These are important for future maintainers. JSDocis a tool that parses inline documentation in JavaScript source files, and produces HTML documentation of the JavaScript code. JSDoc is similar to the java based javadoc tool.
- Use 2 space indents without tab chars. You may need to change the settings on your editor.
- For vi or vim, update .vimrc with the following:
3. Use the correct for-loops. When looping through an object or a hash map, you have to use.vimrcset expandtab set shiftwidth=2
When looping through an array (i.e. something with a length and only numeric keys), you have to usefor (var key in object) { // do something with object[key] }
Failure to do so will cause trouble when using JS frameworks that override the Array object.for (var i=0; i<array.length; i++) { // do something with array[i] }
- For vi or vim, update .vimrc with the following: