day8 Object.assign()方法

合并多个对象

克隆对象(浅);

为对象添加多个方法

Object.assign(SomeClass.prototype, {
  someMethod(arg1, arg2) {
  },
  anotherMethod() {
  }
});​
// 原来的方法
SomeClass.prototype.someMethod = function (arg1, arg2) {​
};
SomeClass.prototype.anotherMethod = function () {
};

let body = Object.assign(ctx.request.body, {
    uId: ctx.session.user.data.id
  })

你可能感兴趣的:(day8 Object.assign()方法)