ES6 对象的扩展运算符(...)用于取出参数对象的所有可遍历属性,拷贝到当前对象之中

setInitialState({ ...initialState, currentUser: undefined });
...initialState = {currentUser: {}, fetchUserInfo: {}, settings: {}}
setInitialState({currentUser: {}, fetchUserInfo: {}, settings: {}, currentUser: undefined })
setInitialState({currentUser: undefined, fetchUserInfo: {}, settings: {}})

使用扩展运算符合并对象:

const obj1={
    name1:"cyy1",
    age1:18
}
const obj2={
    name2:"cyy2",
    age2:28
}
const obj3={
    name3:"cyy3",
    age3:38
}
const obj={
    name:"cyy",
    ...obj1,
    ...obj2,
    ...obj3
}

  

 

https://www.cnblogs.com/chenyingying0/p/12562648.html

 

posted @ 2020-11-27 10:36  wenbolwm  阅读(337)  评论(0编辑  收藏  举报