搜索文档
形参初始值,一般靠后
jsfunction add(a,b,c=10){ console.log(a + b + c); }; add(1,2); // 打印 13结合结构赋值
jsfunction test({ name,age,sex='男' }){ console.log(name,age,sex); // 打印: 张三 21 男 }; test({ name: '张三', age: 21 });
形参初始值,一般靠后
function add(a,b,c=10){
console.log(a + b + c);
};
add(1,2); // 打印 13结合结构赋值
function test({ name,age,sex='男' }){
console.log(name,age,sex); // 打印: 张三 21 男
};
test({
name: '张三',
age: 21
});