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: Implementing $.makeArray()" 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:

This exercise requires you to implement a $.makeArray() method that will convert an Array-like object into a true JavaScript Array.

Get Unlimited Access Now

Transcript from the "Exercise 10: Implementing $.makeArray()" Lesson

>> [MUSIC]

>> Justin Meyer: Next exercise is makeArray This get something that's array like, and converts it into a true JavaScript array.tin This is super useful because there despite us are making our dollar each be cool with if something is array like or not, and still will iterate through it. No matter what you pass it.

[00:00:24] There's a lot of things that really need an array to work and $.makeArray will take whatever it is, and this is in case a no list and run through it and copy it into a real array. So anything you pass this that's array like, that's not really array, dollar array will make it an array.

[00:00:45] So that's our next exercise. You can actually use your new dollar each to make this a little bit easier. The task essentially just make sure these things that are array like are coming back as arrays. You almost could just cheat and turn your dollar is array to return true.

[00:01:07] And then your test would pass, but don't do it that way. So any other questions about how we implement this, again just to to repeat. You really just wanna loop through your thing that's array like and create another array and you can just push items into that array or just add items set array.

[00:01:30] There's other trickier ways of doing this too, where you could still arrays slice methods but we're not you know how to do it that way.