📜  10.4.3.参数是可选函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:50.780000             🧑  作者: Mango

代码示例1
/*Just as it is possible to call a function with fewer arguments than it 
has parameters, we can also call a function with more arguments than it 
has parameters. In this case, such parameters are not available as a 
named variable.

This example calls hello with two arguments, even though it is defined 
with only one parameter.*/

function hello(name = "World") {
   return `Hello, ${name}!`;
}

console.log(hello("Jim", "McKelvey"));