码迷,mamicode.com
首页 > Web开发 > 详细

js spread object

时间:2019-07-12 12:41:27      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:double   ble   com   pre   sde   sample   lte   OLE   fit   

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

标签:double   ble   com   pre   sde   sample   lte   OLE   fit   

原文地址:https://www.cnblogs.com/feng9exe/p/11175323.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!