Skip to content

Comment

一句话解释

comment 是文本 in 你的 code 那个是 ignored 通过 computer — 它 exists 到解释 code 到 human readers.

用大白话说

comment 是一种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.

示例

javascript
// 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 here

Comments 是 ignored 通过解释器. // 是 for 单个行, /* */ for 多个行. TODO comments mark future 工作.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表