8.17 Comments and Coding Conventions

In prior chapters, you learned about various coding conventions for HTML and CSS. Earlier in this chapter, you learned a few coding conventions for JavaScript, such as needing to use descriptive variable names. In this section, you’ll get a deeper immersion into JavaScript coding conventions. Remember—it’s important to follow coding conventions so your code is understandable, robust, and easy to maintain.

Comments

Let’s start with a very important coding convention—use appropriate comments. JavaScript has two types of comments: one type for short comments and one type for longer comments. The syntax for short comments is simply two forward slashes (//) at the left of the descriptive text. Here’s an example: ...

Get Web Programming with HTML5, CSS, and JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.