js spread object

Posted feng9exe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js spread object相关的知识,希望对你有一定的参考价值。

What’s is the benefit / drawback of these two alternatives?

Using object spread

options = ...optionsDefault, ...options;

Or using Object.assign

options = Object.assign(, optionsDefault, options);

 

Code Sample (doubles as compatibility test)

var x = a: 1, b: 2 ;

var y = c: 3, d: 4, a: 5 ;

var z = ...x, ...y;

console.log(z); // a: 5, b: 2, c: 3, d: 4

 

https://stackoverflow.com/questions/32925460/object-spread-vs-object-assign

以上是关于js spread object的主要内容,如果未能解决你的问题,请参考以下文章