美文网首页
Object.assign(target,...sources)

Object.assign(target,...sources)

作者: Allan要做活神仙 | 来源:发表于2017-02-20 14:21 被阅读10次

The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object.
It will return the target object.

target
The target object.
sources
The source object(2).

Return value
The target object.

var obj = { a: 1 };
var copy = Object.assign({}, obj);
console.log(copy); // { a: 1 }

Object.assign()

通过复制一个或多个对象来创建一个新的对象。

相关文章

网友评论

      本文标题:Object.assign(target,...sources)

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