争渡,争渡,惊起一滩鸥鹭

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

Object.assign方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象(target)。

const target = { a: 1, b: 1 };

const source1 = { b: 2, c: 2 };
const source2 = { c: 3 };

Object.assign(target, source1, source2);
target // {a:1, b:2, c:3}

 

参考文档:https://www.jianshu.com/p/d5f572dd3776

 

posted on 2020-04-08 19:37  争渡~  阅读(141)  评论(0编辑  收藏  举报