ES6中默认参数和剩余参数的注意事项
参数有了默认参数值,不允许重复参数名
//抛出异常 Duplicate parameter name not allowed in this context
//在此上下文中不允许重复参数名
function test2(param=123,param){
...
}
剩余参数必须是最后一个形式参数
//抛出异常 Rest parameter must be last formal parameter
//Rest参数必须是最后一个形式参数
function fun(...param,param1){
...
}
不能给剩余参数,设置默认值
//抛出异常 Rest parameter may not have a default initializer
//不能给剩余参数,设置默认值
function fun(param,...param1=[1,2,3]){
...
}