Sample Video Frame

Created by Zed A. Shaw Updated 2024-12-10 18:57:40

02: Comments

A comment is a way for you to write down notes that the computer ignores. These notes are meant to be something for other people to read when trying to understand your code. JavaScript has two main ways that you write comments, and this code shows you how to do that.

The Code

View Source file code.js Only

// This is a comment, everything after is ignored.

console.log("I am Code");

/* This is also a comment. You use this for
 * longer things that you want to say.
 */

console.log("So am I");

// The code inside the next comment will not run:

/*
console.log("I will not run.");
*/

As with Exercise 1, you should type this code in and try to make your file match my file as exactly as you possibly can. Try to focus on the details, and get all the details right before you move on. You should also, as as I've said before, do this in small chunks, and modify the file when you're done to try other things. For example, can you comment out this entire file?

What You Should See

I am Code
So am I
Previous Lesson Next Lesson

Register for Learn JavaScript the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.