2021
06-05
06-05
JS ES6展开运算符的几个妙用
1.添加属性复制对象的同时,为其添加新的属性。例子中复制了user对象到userWithPass,并添加了password属性。constuser={id:110,name:'KaysonLi'}constuserWithPass={...user,password:'Password!'}user//=>{id:110,name:'KaysonLi'}userWithPass//=>{id:110,name:'KaysonLi',password:'Password!'}2.合并多个对象利用...可以合并多个对象到一个新的对象。part1和part2合并到user1:constpart...
继续阅读 >