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...
On this page of the site you can watch the video online javascript - Object spread vs. Object.assign with a duration of hours minute second in good quality, which was uploaded by the user Code Samples 13 April 2024, share the link with friends and acquaintances, this video has already been watched 184 times on youtube and it was liked by 4 viewers. Enjoy your viewing!