Comment
In one line
A comment is text in your code that is ignored by the computer — it exists to explain the code to human readers.
In simple words
A comment is a note you write inside your code that the computer completely ignores. It is there for humans — yourself, your teammates, or anyone reading the code later — to explain what the code does, why it was written a certain way, or to leave reminders.
Good comments explain WHY, not WHAT. The code itself shows what it does; the comment should explain the reasoning, constraints, or business logic that are not obvious from reading the code.
Different languages use different comment syntax: // in JavaScript/C/Java, # in Python/Ruby, /* */ for multi-line comments in C-like languages. Comments are also used to temporarily disable code during debugging.
Example
// This is a single-line comment
let x = 5; // Initialize counter
/*
This is a multi-line comment.
It can span several lines.
*/
// TODO: add validation hereComments are ignored by the interpreter. // is for single lines, /* */ for multiple lines. TODO comments mark future work.
Related terms
Related Resources
Related Lessons
- Comments and Readability
Learn about comments and code readability.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.