Transcript from the "Objects Exercise" Lesson
>> Let us try our hand at object summoning. So, we're gonna take a moment to create an object that represents you. And you get to decide what properties this object has and what values those properties point to. So for example, in my object, I'm going to declare with const cuz I'm not gonna change, I'm gonna be Anjana the rest of my life.
[00:00:26] So I'm gonna name it Anjana. And in this object, I'm going to declare some properties that matter to me. Like my home is in San Francisco. I speak a few different languages. So I'm gonna make an array value for different languages. I don't have a pet, which makes me very sad.
[00:00:44] So pet is null. I have a Vespa that I drive around. So that's my vehicle, and I have an array of different hobbies. Now you get to decide what is in your object. Let's say put a name cuz your name is how we refer to you. So let's have a name property, and then whatever other properties you want of stuff you care about.
[00:01:27] Anything new that I didn't have up here? So we talked about one, for example, maybe you have more than one vehicle. So OJ, you put what property?
>> Vehicles. And what kind of value, what type of value does vehicles point to in your-
>> In another array.
>> An array, right, for multiple things. Cool, did anybody else declare any other properties on their object?
>> I put my kids names.
>> Kids, kids is a great one. Or kids names, yeah. Anything else? Maybe from the chat, yeah?
>> Pet type.
>> Pet type, yeah. Pet type, exactly, and what value did you have for that?
>> Dog, so string dog, gotcha. Nice, cool, so this is just suffice it to say that objects are whatever we make them to be, we can decide what the properties are.
>> So if you want to do like pets and you want it to have multiple values, can you create a sub object within the pet kinda thing and it says, I don't know, dog one, whatever, dog two, whatever?
>> Yeah, so we have here, we already have a couple of examples of using an array as a value within the object to store multiple things.
[00:03:18] We'll look at a couple examples later, great question. We had a question about array.join, and I would say that in general, if you're wondering, does this particular thing like .join, does it work with this time value? Or does it work with that kind of value? Or what happens in that case?
[00:03:38] So I would say as I have been saying the whole time, you can check out the full documentation on MDN. To figure out what type of stuff you can pass into it, what options you have, like for example with join, you don't even have to pass in a separator and it will just join them with no separator.
[00:03:58] But if you're wondering kind of like what happens if I pass in some other separator there? Then you can check out the documentation, and usually that'll answer your questions, as generally, usually that'll answer any questions you have about a specific operator or keyword or a spell on a string, that sort of thing.
[00:04:50] So for example, I could freeze my Anjana object if I think I'm never gonna get a pet, let's say. My pet is always gonna be a null. That would be a very sad life. I hope I get a pet someday. [LAUGH] But I could freeze it in place so that I cannot re-assign to the properties I already have.
[00:05:10] And I cannot do what I did before when I did dot snack equals and just insert a new property in there. So again, if you wanna know more details about how freeze works, check out the MDN documentation. And then I think we had another question about the spread operator or spread syntax.
[00:05:31] Is that right?