Skip to content

参数

一句话解释

参数 是 named placeholder in 函数 定义 那个 接收 值 当 函数 是 called.

用大白话说

A parameter is a variable listed in the function definition. It is a placeholder — a named slot that says " 值将 go 这里当 这个函数是 called." The parameter has no value of its own until the function is invoked.

For example, in 函数 greet(name) { ... }, name is a parameter. It describes what kind of input the function expects. The actual value (like "Ada") is called an argument and is supplied by the caller.

Parameters define the shape of a function's inputs. A function with parameters 函数添加(, b) expects two values. The names you choose for parameters document what each input means, making the function easier to read and use correctly.

示例

javascript
// 'name' and 'greeting' are PARAMETERS
function greet(name, greeting) {
  console.log(greeting + ", " + name);
}

// "Ada" and "Hello" are ARGUMENTS
greet("Ada", "Hello"); // Hello, Ada

name and greeting 是参数 (placeholders in 定义). "Ada" and "Hello" 是实参 (实际值 通过 at call 时间).

常见混淆

  • 容易混淆的对象: 实参

    关键区别: 参数是 named placeholder in 函数定义; 实参是 实际值 你通过 in 当 calling 函数. 参数是 in declaration, 实参是 at call site.

相关术语

相关资源

相关课程

  • 函数

    参数是 introduced 使用函数

解读错误信息

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

查看错误

← 返回术语表