Watching:

Add comments to code for human Learn Programming


show more Adding comments in JavaScript is a great way to track progress and remind yourself what you were working on last week, or even last year. Comments are most often single lines of "notes" added to code for later reference. Simon discusses single and multi-line comments and covers their common uses and gives guidance on when to use and where to place comments for human understanding. show less
please wait ...

Adding comments to code for human understanding

Once you've written more than a handful of lines of JavaScript or indeed any programming language, you are going to want to start adding comments to your code so it can remind you what you were trying to do a week ago or six months ago or a year ago. You add comments in JavaScript the same way as in the other C-based languages. The most simplest way of doing this is to actually write a line that begins with two forward slashes. Anything after two forward slashes will be ignored. So this is a single line comment.

As soon as we leave that line, the rest of our code will be processed as normal. You can actually use those two forward slashes and even put them after an existing line, but it is more common to put them before the code that they are meant to be applying to. So if I was trying to split up some of my code here, I might say that this section was my Boolean variables and this previous one was my numeric variables. Obviously, these are pretty sel explanatory here.

It's quite co...

Adding comments to code for human understanding
Video duration: 1m 49s 4h 47m Beginner

Viewers:

Adding comments in JavaScript is a great way to track progress and remind yourself what you were working on last week, or even last year. Comments are most often single lines of "notes" added to code for later reference. Simon discusses single and multi-line comments and covers their common uses and gives guidance on when to use and where to place comments for human understanding.

Subjects:
Developer Web
Author:
please wait ...