Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ToniRib/b42ca094d88b143b0090 to your computer and use it in GitHub Desktop.
Save ToniRib/b42ca094d88b143b0090 to your computer and use it in GitHub Desktop.
Checks for Understanding

Array Prototype Methods

I understand that functions in JavaScript can take any number of arguments.

  • Yup. It's weird, but super flexible. I like the idea of being able to omit arguments that I don't need.

I can describe the similarity between blocks in Ruby and anonymous functions in JavaScript.

  • Blocks in ruby and anonymous functions in JS both can arguments of some type (often a collection) and will run some code related to those arguments. In JS we can pass arguments into an anonmyous function and do something with them inside of that to return some value, which is very similar to ruby. In the same way that we can pass a block to .each in ruby, we can pass an anonymous function to .forEach in JS.

Where are the methods available to all arrays (e.g. forEach, map, etc.) defined?

I can explain the difference between using a for loop and the forEach method.

  • forEach actually goes over a collection, running an anonymous function once for each element of the collection. for allows you to define a start, stop, and step and can be used for things like going over multiple arrays at once or really anything that you might need to be more dynamic.

I can explain the difference between forEach and map.

  • Similar to ruby, map actually returns a new array that you can store in a variable, while forEach does not and you have to push the new elements into a new array one at a time. forEach returns undefined when finished.

Can you explain the process of taking a plain JavaScript objects, transforming them into DOM nodes, and appending them to the page.

  • You can use document.createElement and then set the properties of that element (like alt or src for an image) similar to how you would set javascript object properties. Then you can use appendChild or jQuery's append to add it to the page in the correct location.

How comfortable are you using the forEach() method?

  • Very comfortable. It's super similar to ruby so it isn't that difficult to figure out the logic.

How comfortable are you using the map() method?

  • Also very comfortable, for the same reasons as forEach.

How comfortable are you using the filter() method?

  • Fairly comfortable, I just haven't used it that much so I need to use it more to feel better about it.

How comfortable are you using the reduce() method?

  • Semi-comfortable. Again, I need more practice. I've never been a major user of reduce in ruby so this is also probably why I don't feel as comfortable with it.

How comfortable are you using the sort() method?

  • I would feel more comfortable if there were tests for this in the exercises!

How comfortable are you working with simple unit tests in Mocha in the browser?

  • Pretty comfortable. I haven't written any yet, but it wasn't difficult to follow along and use them for this lecture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment