DEV Community

Discussion on: Javascript: An introduction to Object constructor.

Collapse
 
gladgladwrap profile image
Dylan Cooper

Nice Object tips but there are a few typos. In your first example with Object.assign(), the new object will contain: { a: 1, b: 2, c: 6, d: 4, e: 4 }. If you omit the empty object parameter in Object.assign(), newObj will again contain: { a: 1, b: 2, c: 6, d: 4, e: 4 }. obj1 will be merged with obj2 to also contain { a: 1, b: 2, c: 6, d: 4, e: 4 }, and obj2 will not be altered. And in your last examples, don't forget to initialize/assign a value to 'valueObj' before using it.

Collapse
 
yongliang24 profile image
Yong Liang

thank you for your comments.