6

Commenting Your Code…FTW!

In this Chapter

  • Learn how to comment your code

  • Figure out the best practices around commenting

Everything we write in our code editor might seem like it is intended for our browser’s eyes only:

let xPos = -500;
 
function boringComputerStuff() {
  xPos += 5;
 
  if (xPos > 1000) {
    xPos = -500;
  }
}
boringComputerStuff();

As we will soon find out, that isn’t the case. There is another audience for our code, and that audience is made up of human beings.

Our code is often used or scrutinized by other people. This is especially true if you and I are working on a team with other JavaScript developers. We’ll often be looking at their code, and they’ll often be looking at our code. To make all ...

Get Javascript Absolute Beginner's Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.