{
//有默认值的后面如果有参数必须要有默认值
function test(x,y="world"){
console.log(x,y)
}
test('hello');//hello world
test('hello',"kill");//hello kill }
{
let x='test';
function test2(x,y=x){
console.log('作用域',x,y);
}
test2('kill');//kill kill
function test3(c,y=x){
console.log('作用域',c,y);
}
test3('kill');//kill test
}
{
//如果参数是arg,不可以有其他参数
function test3(...arg){
for(let v of arg){
console.log('rest',v);
}
}
test3(1,2,3,4,'a');
}
{
console.log(...[1,2,4]);//1 2 4
console.log('a',...[1,2,4]);//a 1 2 4
}
//箭头函数
{
// 函数名 参数 返回值
let arrow = v => v*2;
console.log(arrow(3));// let arrow2=()=>5;
console.log(arrow2())
}