实际参数

实际参数(Argument)是作为输入传递给函数,可以是原始值对象

例如:

js
const argument1 = "Web";
const argument2 = "开发";
example(argument1, argument2); // 传递两个实际参数

// 该函数接受两个值
function example(parameter1, parameter2) {
  console.log(parameter1); // 输出 = "Web"
  console.log(parameter2); // 输出 = "开发"
}

函数调用中的实际参数顺序应与函数定义中的形式参数顺序相同。

js
const argument1 = "foo";
const argument2 = [1, 2, 3];
example(argument1, argument2); // 传递两个实际参数

// 该函数只接受一个值,因此传递的第二个实际参数将被忽略
function example(parameter) {
  console.log(parameter); // 输出 = foo
}

参见