Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions object.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// people, stuff and state constant variables so they remain unchanged

const people = ['Kookla','Fran','Ollie'];

const stuff = {
Expand All @@ -17,6 +19,24 @@ const newStuff = { ...stuff, cars: [...stuff.cars, 'Honda']};

let newState = {...state, people: ['Odie', ...people, 'Garfield'], stuff:{...stuff, cars: [...stuff.cars, 'Honda']}};

console.log(newPeople);
console.log(newPeople); // [ 'Odie', 'Kookla', 'Fran', 'Ollie', 'Garfield' ]

console.log(newStuff);
console.log(newState);
/*
{ tv: 'huge',
radio: 'old',
toothbrush: 'frayed',
cars: [ 'Toyota', 'Mazda', 'Honda' ] }
*/

console.log(newState);
/*
{ people: [ 'Odie', 'Kookla', 'Fran', 'Ollie', 'Garfield' ],
stuff:
{ tv: 'huge',
radio: 'old',
toothbrush: 'frayed',
cars: [ 'Toyota', 'Mazda', 'Honda' ]
}
}
*/