1'use strict';
2
3// Merge an object
4let first = {name: 'Tony'};
5let last = {lastName: 'Stark'};
6let person = Object.assign(first, last);
7ChromeSamples.log(person);
8// {name: 'Tony', lastName: 'Stark'}
9ChromeSamples.log(first);
10// first = {name: 'Tony', lastName: 'Stark'} as the target also changed
11
12// Merge multiple sources
13let a = Object.assign({foo: 0}, {bar: 1}, {baz: 2});
14ChromeSamples.log(a);
15// {foo: 0, bar: 1, baz: 2}
16
17// Merge and overwrite equal keys
18let b = Object.assign({foo: 0}, {foo: 1}, {foo: 2});
19ChromeSamples.log(b);
20// {foo: 2}
21
22// Clone an object
23let obj = {person: 'Thor Odinson'};
24let samp = {person: 'ashok'};
25let clone = Object.assign({}, obj, samp);
26ChromeSamples.log(clone);
27
28// {person: 'Thor Odinson'}