Let’s say I have an options variable and I want to set some default value.
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);
This is the commit that made me wonder.
here: https://github.com/tc39/proposal-obje...
spread defines properties, whilst Object.assign() sets them: http://2ality.com/2016/10/rest-spread...
Watch video javascript - Object spread vs. Object.assign online without registration, duration hours minute second in high quality. This video was added by user Code Samples 13 April 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 184 once and liked it 4 people.