1// We want to update status property value to 'online'
2const data = {
3 user: 'CamperBot',
4 status: 'offline',
5 friends: '732,982',
6};
7
8// Object.assign takes in a target object (1st parameter) and source objects
9// (rest of the parameter list). Source object properties are mapped to the
10// target object (which is usually empty). Any matching properties are
11// overwritten by the source objects
12const newObject = Object.assign({}, data, {status: 'online'})
13
14console.log(newObject)
15/*
16 {
17 user: 'CamperBot',
18 status: 'online',
19 friends: '732,982',
20 }
21*/