The assign() method on the Object constructor in JavaScript is used to merge multiple objects together. You can use it to merge as many objects as you like.
If multiple objects have the same property, the "merged object" will also contain that property but the value of it will come from the last object passed in as an argument. This means it can be used to easily create "default options" within a function.
In this video I take you through examples of how you can use the Object.assign() method and also an example of using it to create default options in a function.
Support me on Patreon:
/ dcode - with enough funding I plan to develop a website of some sort with a new developer experience!
For your reference, check this out:
https://developer.mozilla.org/en-US/d...
Follow me on Twitter @dcode!
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
On this page of the site you can watch the video online The Object.assign() Method in JavaScript - Set default options for functions with a duration of hours minute second in good quality, which was uploaded by the user dcode 21 June 2018, share the link with friends and acquaintances, this video has already been watched 23,212 times on youtube and it was liked by 534 viewers. Enjoy your viewing!