Just as there is a spread operator for arrays, there is a spread operator for objects. Object spread allows you to push values from one object to another using the three-dot operator. In this video, learn how to spread values into objects for easier to read code.
- [Instructor] In an earlier video, we looked at … how you can use the spread operator with arrays. … in this video, we'll take a closer look … at how to use the spread operator with objects. … So I'm going to create an object here called daytime. … Inside of the daytime object, … it's going to have keys for breakfast. … We'll have some oatmeal. … And then for lunch, we'll have peanut butter and jelly. … Then we're going to go ahead … and create a variable called nighttime. … This is going to be equal to mac and cheese. … So now what we want to do is we want to create sort of a menu. … We want to create an object that contains both our breakfast, … lunch, and nighttime items. … So we could try this just by adding daytime and nighttime … to our backpackingMeals. … But if we console.log this, … we see the same situation as with the array. … We see some nesting going on where we don't want it to be. … We want to take both the breakfast and the lunch items … and put them at the same level as the nighttime. …
This course was created by Eve Porcello. We are pleased to offer this training in our library.
- What is ECMAScript?
- Writing and searching strings
- Writing maps
- Destructuring arrays
- Searching arrays
- Creating objects
- Destructuring objects
- Iterating with the for/of loop
- Getting and setting class values
- Using ECMAScript functions
- Building and returning promises
- Using async/await syntax
Skill Level Intermediate
1. What Is ECMAScript?
What is ECMAScript?1m 44s
2. ECMAScript Variables and Data Structures
3. Arrays and Array Methods
Destructuring arrays1m 34s
4. ECMAScript Objects
5. ECMAScript Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.