From the course: Learning ECMAScript 6+ (ES6+)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Enhancing object literals - JavaScript Tutorial
From the course: Learning ECMAScript 6+ (ES6+)
Enhancing object literals
- [Instructor] Think about an object, any object. Mine is going to be a skier. What I want to do is I want to build a function that is going to return an object that's going to return this skier. So the skier will take in a name and a sound. Something that they yell when they're excited about skiing. And the skier will then return an object that builds together the name and the sound and a powder yell. So powder yell just means if it's really snowy, you're going to get excited and you have to yell. So we're going to go ahead and use let yell and I'll set that equal to this.sound.touppercase so it'll take that sound string and make it uppercase. And then we'll console log the message using a template string. Now when I call this function here on line 12, I'm going to send it a name and then I'll send it some sort of yell. Now we see that skier is a function that we've created. Let's go ahead and console log the skier…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Enhancing object literals2m 8s
-
(Locked)
Creating objects with the spread operator1m 25s
-
(Locked)
Destructuring objects3m 2s
-
(Locked)
Iterating with the for/of loop2m 40s
-
(Locked)
Introducing classes2m 28s
-
(Locked)
Inheritance with JavaScript classes1m 39s
-
(Locked)
Getting and setting class values3m 35s
-
(Locked)
-
-
-