es6 参数的一些处理

使用的es6 对象的解构赋值和扩展运算符

es6 参数的一些处理_第1张图片

function wrapperFunction({x, y, ...restConfig}) {
	console.log (restConfig)
}
wrapperFunction({x:"x", y:"y", a: 1, b: 2})
// {a: 1, b: 2}

使用了 es6 函数 的 rest参数

es6 参数的一些处理_第2张图片

function wrapperFunction(x, y, ...restConfig) {
	console.log (restConfig)
}
wrapperFunction("x", "y", {a: 1, b: 2})

运行结果如下:es6 参数的一些处理_第3张图片

使用的对象的扩展运算符

es6 参数的一些处理_第4张图片

function wrapperFunction(x, y, {...restConfig}) {
	console.log (restConfig)
}
wrapperFunction("x", "y", {a: 1, b: 2})  // {a: 1, b: 2}

你可能感兴趣的:(es6/es7,扩展运算符,解构赋值,rest参数,es6)