Comment

A comment is a note in the source code that the computer ignores. Comments explain what the code does for the humans reading it.

General Programming

Good comments explain why something is done, not just what, since the code already shows the what. Most languages use a symbol like # or // to start a comment.

Examples

Python

# Calculate the total with tax
total = 100 * 1.2
print(total)

Output:

120.0

JavaScript

// Greet the user
console.log("Hello");

Output:

Hello

See also

Back to the Dictionary