扫码关注官方订阅号
export default { ...user, ...utils, ...message, ...topic };
欢迎选择我的课程,让我们一起见证您的进步~~
以上两位都没答到点上。这是针对对象的展开操作符,注意,是对象,即{ x, y, ...z },尚未进入es标准,目前处于Stage 3。目前的标准是数组的展开操作符,即[x, y, ...z],已经在es6标准中。
{ x, y, ...z }
Stage 3
[x, y, ...z]
数组的不说了,说对象的:
// Rest properties let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; console.log(x); // 1 console.log(y); // 2 console.log(z); // { a: 3, b: 4 } // Spread properties let n = { x, y, ...z }; console.log(n); // { x: 1, y: 2, a: 3, b: 4 }
回到原题
相当于
export default Object.assign({},user,utils,message,message,topic);
参见:https://github.com/sebmarkbag...
es6 iterator
// 例一 var str = 'hello'; [...str] // ['h','e','l','l','o'] // 例二 let arr = ['b', 'c']; ['a', ...arr, 'd'] // ['a', 'b', 'c', 'd']
没事儿多去看看规范。扩展运算符
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
以上两位都没答到点上。
这是针对对象的展开操作符,注意,是对象,即
{ x, y, ...z },尚未进入es标准,目前处于Stage 3。目前的标准是数组的展开操作符,即[x, y, ...z],已经在es6标准中。数组的不说了,说对象的:
回到原题
相当于
参见:https://github.com/sebmarkbag...
es6 iterator
没事儿多去看看规范。
扩展运算符