美文网首页
day8 Object.assign()方法

day8 Object.assign()方法

作者: qqqc | 来源:发表于2017-08-08 17:24 被阅读0次

合并多个对象

克隆对象(浅);

为对象添加多个方法

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()方法

      本文链接:https://www.haomeiwen.com/subject/lcxxrxtx.html