Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
The {} in the assign method is used top create a new empty object. Then the second argument is copied into the empty object creating an identical copy. Then the third argument is also a object, but, in this case, is used to change the values of the members of the new copy of the object. Basically the three objects are merged together, in sequence, to create a new one. If any members from the next object don't exist in the previous then they are added to the new object. If they do exist then their values are updated. https://codesquery.com/es6-object-assign/ You can also use a class with the new keyword to create an object. It's a bit more like most other OOP programming languages. https://www.sololearn.com/learn/JavaScript/2979/
15th May 2020, 1:03 PM
ChaoticDawg
ChaoticDawg - avatar