This course is out of date and does not reflect Frontend Masters current standards. We now recommend you take the JavaScript: The Hard Parts course.

Check out a free preview of the full Advanced JS Fundamentals to jQuery & Pure DOM Scripting course:
The "Exercise 10: Solution" Lesson is part of the full, Advanced JS Fundamentals to jQuery & Pure DOM Scripting course featured in this preview video. Here's what you'd learn in this lesson:

Justin walks through the solution to exercise 10.

Get Unlimited Access Now

Transcript from the "Exercise 10: Solution" Lesson

>> [MUSIC]

>> Justin: I'm gonna go through the answer to makeArray. There's a lot of high performance ways of doing that that I'm not gonna, faster performing ways of doing it that I'm not gonna really go into. I'm gonna do the most simple I think to understand explanation. I'm just going to create an array,

>> Justin: Let me scroll this up to the top here. And I'm gonna use my $.each, pass it my array like thing.
>> Justin: And I'm gonna get the index or the property, which I'm just gonna call I. And I'm gonna get the value. And I'm just gonna push in,

>> Justin: The value,
>> Justin: And I'm gonna return array.
>> Justin: Stephen asked on the chat room what happens if this is an object and not something that's array like? Can anybody answer that, what they think would happen with this code here? If let's say I had an object that looked like, foo, bar, zed, ted?

[00:01:28] Okay
>> Speaker 2: It will return an array of values.
>> Justin: It would return an array of values, what would be in there?
>> Speaker 2: Bar and ted.
>> Justin: What?
>> Speaker 2: Bar and ted.
>> Justin: Bar and ted, yeah exactly right, good job. So this works even if someone passes an object, it'll return an array of all of the values on the object and none of the properties.

[00:01:51] Which might not be what you want but mostly typically you're using makeArray with something that's array like. Any other questions? Cool, all right, so
>> Justin: Let me make sure my test is passing that I actually, I'm showing you guys how to write it right, awesome. All right, now for $proxy, last one of these but a very useful one to understand.