Transcript from the "Arrays vs Objects" Lesson
>> Bianca Gandolfo: Arrays, so what do we know about arrays?
>> Speaker 2: Container.
>> Bianca Gandolfo: Array is a container, just like an object, it's a data structure. [CROSSTALK] Yeah, so we can have an ordered list in our array.
>> Speaker 2: You can nest them.
>> Bianca Gandolfo: Yeah, you can nest them. You can save any data type as a value in your array just like an object.
>> Speaker 2: No.
>> Bianca Gandolfo: Anything else?
>> Speaker 3: An array is an object?
>> Bianca Gandolfo: Yeah, an array is as an object. If you're coming from an object oriented language, you could think of an array as a subclass of an object in that it inherits from an object. If that doesn't mean anything to you, don't worry about it, but that might sort of clarify for those who've had that background.
[00:01:23] But at it's core, what's important to note is that an array is an object and so the rules are going to be the same. We're gonna explore that and then we're gonna talk a lot about how arrays are objects. And then we're gonna talk a little bit about how arrays are different than objects.
[00:01:41] Cool. Just an overview, arrays versus objects, we're gonna be talking about access && assignments, we're gonna be talking about native methods && properties. When I say native, all I mean is it comes with a language, cuz there's some methods that you get from libraries, such as the underscore library, which we'll cover tomorrow but there's also methods that just come out of the box.
[00:02:01] You can just open your console and say like, array dot and then, actually that's not working.
>> Bianca Gandolfo: And then you can say array dot, and then we have all of these methods that just come out of the box. Some of them you might be familiar with. And then we're also gonna talk about iteration techniques and how they're different for arrays and the same.
[00:02:32] when would we use an array versus an object? When would you choose to use one versus the other?
>> Speaker 2: [INAUDIBLE]
>> Bianca Gandolfo: Yeah, so if you want it to be ordered.
>> Speaker 2: Doesn't have named properties.
>> Bianca Gandolfo: Yeah, so if it doesn't make sense for it to have named properties, like maybe you have like a bunch of names.
[00:02:56] You could say var names equals and then you could put like the names of. Here let me put that up and then you could put the names of your pets.
>> Bianca Gandolfo: Whatever your pets are.
>> Bianca Gandolfo: Does anyone have a pet, pet name?
>> Speaker 4: Wonder Woman.
>> Bianca Gandolfo: Wonder Woman?
[00:03:23] That's a good one. This just makes sense for it to be a series, can you guys see that in the back? Because it's all the same thing, they're all names, so you wouldn't want to say like var names and then have an array and just be like name1.
[00:03:41] That's not adding to the data, that's just adding extra data that's not important. Maybe they're all the same thing, you don't need a key-value pair, it's ordered. What else? Maybe you want to use the array methods that come with it. Maybe you want to be able to sort, maybe you want to do something with the length property.
[00:04:06] What else? That's all I can think of right now. But yeah, so there's certain use cases for arrays and objects and so you need to choose wisely.