Skip to content

Keyword

一句话解释

keyword 是 reserved word 那个有 特殊 meaning in language and cannot 是 used as 变量 name.

用大白话说

keyword 是 word 那个 programming language reserves for 它的 own use. Keywords 定义语法 and 结构的 language — things 如 let, if, for, function, return, class, while.

Because keywords have special meaning, you cannot use them as variable or function names. You cannot write let 如果 = 5; because 如果 is a keyword. Each language has its own set of keywords: JavaScript has about 60, Python about 35, Java about 50.

Keywords are how you talk to the computer in its own language. When you write 如果 (x > 0), the keyword 如果 tells the interpreter "这个是 conditional 语句." Learning the keywords of a language is a big part of learning the language itself.

示例

javascript
// Keywords in JavaScript:
let x = 5;        // 'let' is a keyword
if (x > 0) {       // 'if' is a keyword
  return x;        // 'return' is a keyword
}

// This would cause an error:
// let let = 10;   // 'let' cannot be a variable name

let, 如果, 返回, 函数, for, 虽然, const, 类是 所有 keywords. 它们 cannot 是 used as identifiers.

相关术语

相关资源

相关课程

解读错误信息

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

查看错误

← 返回术语表