输入参数:函数从外部接收数据的参数。function double(num) {
return num * 2;
}
let result = double(5);
输出参数:函数向外部返回数据的参数。function getFullName(firstName, lastName, fullName) {
fullName.value = `${firstName} ${lastName}`;
}
let fullName = { value: '' };
getFullName('John', 'Doe', fullName);
console.log(fullName.value);
输入输出参数:既可以接收数据也可以返回数据的参数。function updatePerson(person, name, age) {
person.name = name;
person.age = age;
return person;
}
let alice = { name: 'Alice', age: 30 };
let updatedAlice = updatePerson(alice, 'Alice Smith', 31);
console.log(updatedAlice);