Video Lesson

Lesson Notes

JavaScript Comments Explained (Simple)

Comments let you leave notes or disable code without affecting execution.

Single-Line Comments

Use // to comment out a single line:

1// This is a single-line comment 2console.log("This will run"); 3// console.log("This will NOT run");

Multi-Line Comments

Use /* ... */ to comment out multiple lines:

1/* 2 This is a multi-line comment. 3 You can write as many lines as you need 4 without adding // to each line. 5*/ 6console.log("Code after a multi-line comment");

When to Use Comments

  • Explain complex logic
  • Leave TODOs or reminders for yourself
  • Disable code temporarily for testing
  • Provide references (links, docs, examples)
1// TODO: Refactor this function for performance 2 3/* 4 Example usage: 5 fetchData().then(data => { 6 console.log(data); 7 }); 8*/

AI Assistant

Sign In Required

Sign in and subscribe to use the AI assistant for instant help with your lessons.

Sign In

Code comments

In this lesson, students will discover the essential role of comments in JavaScript, learning how to effectively use single-line and multi-line comments to enhance code readability, document logic, and streamline debugging. Elevate your coding skills by mastering the art of commenting to clarify your thought process and improve collaboration!

3m 2s

Course Content

0 of 32 lessons completed
6. Promises, Async and Await
0 of 0 completed
7. The DOM
0 of 0 completed