1.函数可以设置参数默认值
1 function test1(x,y=1){
2 console.log(x,y)
3 }
4 test1(10)//10 1
2.rest参数.....b){
2 for(let i of b){
3 a+=i
4 }
5 console.log(a)
6 }
7 // 说明传入的参数是一个一个的传入...,而不是数组形式
8 test2(100,1,2,3) //106
9 test2(100,[1,2,3,4])//1001,2,3,4
注意:如果有rest参数,那么它一定是最后一个参数...”:
1 function test21(a,b){
2 console.log(a+b)
3 }
4 // ...后面跟上数组好比是rest参数的逆运算
5 test21...注意:箭头函数中this指向的是定义时所在的对象,不同于普通函数this指向的是运行时所在对象
1 function Test10(){
2 this.name='apple',
3