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...
En esta página del sitio puede ver el video en línea javascript - Object spread vs. Object.assign de Duración hora minuto segunda en buena calidad , que subió el usuario Code Samples 13 abril 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 184 veces y le gustó 4 a los espectadores. Disfruta viendo!