Skip to content

实参

一句话解释

实参是 实际值 你通过到 函数当 你 call 它, filling 参数's slot.

用大白话说

argument 是the concrete value you provide when calling a function。 If the function is a form with blank fields (parameters), the arguments are the values you write into those fields before submitting.

例如, 添加(2, 3) calls the 添加 function with arguments 2 and 3. These values are assigned to the function's parameters and used inside the body to compute the result.

Arguments can be literals (5, "hi"), variables (userAge), or even the result of another function call (添加(multiply(2, 3), 4)). The number and order of arguments must match the function's parameters.

示例

javascript
function add(a, b) {
  return a + b;
}

// 2 and 3 are ARGUMENTS (values at call time)
const result = add(2, 3);
console.log(result); // 5

// Arguments can be variables too
let x = 10, y = 20;
console.log(add(x, y)); // 30

2 and 3 是实参 — 实际值 通过到 添加. 它们 fill 参数 slots ` and b`.

常见混淆

  • 容易混淆的对象: 参数

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

相关术语

相关资源

相关课程

  • 函数

    实参是 introduced 使用函数

解读错误信息

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

查看错误

← 返回术语表