语句
一句话解释
语句是 单个 instruction 那个 computer 执行, 如 assigning 变量 or calling 函数.
用大白话说
语句是 完整 instruction 那个 tells computer 到做 某事. 它是 smallest standalone 单元的 executable code. let x = 5; 是语句 — 它 declares 变量 and assigns 值. console.log("hi"); is a statement — it prints text.
Statements are the building blocks of a program. A program is a sequence of statements executed one after another. Each statement typically ends with a semicolon (;) in JavaScript, C, and Java, or a newline in Python.
Common types of statements include: assignment (x = 5), conditional (如果 (x > 0) {...}), loop (for (...) {...}), declaration (let y), and return (返回 result). Some statements contain expressions (like x = 2 + 3), but not all expressions are statements.
示例
let x = 5; // declaration + assignment statement
if (x > 0) { // conditional statement
console.log("positive"); // expression statement
}
for (let i = 0; i < 3; i++) { // loop statement
console.log(i);
}每个行 是语句. program 执行它们 in 顺序: declare x, 检查条件, 循环.
相关术语
相关资源
相关课程
- 如何 Programs 工作
学习关于语句 and execution.
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。