- Open your command-line application and navigate to your workspace.
- Create a new folder named 06-10-spread-operator-combine.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file with an async function named main, which creates a couple of objects and a constant. It then uses the spread operator and object structuring to combine them into a single object:
// main.jsexport function main() {
const object1 = {
prop1: 'some value',
prop2: 'some other value',
}
const object2 = {
prop2: 'some overriding value',
objectProp: { foo: 'bar' }
}
const anotherProp = Math.random();
const combinedObject = { ...object1, ...object2, anotherProp };
console.log(combinedObject);
}
- Start your Python ...