Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ShannonPaige/a246aafaa8180746ba3d to your computer and use it in GitHub Desktop.
Save ShannonPaige/a246aafaa8180746ba3d 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.

Check

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

Yep

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

MDN

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

They are both ways to iterate over an array, but forEach has the advantage of being easier to read, and it doesn't introduce the global variable 'i', which can cause issues

I can explain the difference between forEach and map.

Just like in ruby, if I find myself altering the contents of each element of the array, it's better practice to use map to do this rather than to create an array and use forEach to alter the items and cram them in an array.

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

Not really... something about createElement. After the element is made, then using appendChild to add the element to the page.

How comfortable are you using the forEach() method?

Think I'm good on this one.

How comfortable are you using the map() method?

Yeah, good on this one too.

How comfortable are you using the filter() method?

The modulo example was opposite of what I would expect, since you were returning %2, so the even ones came back 0 and got filtered since 0 is falsey. It feels like it filters out elements that satsify the condition...but I think I can get used to it.

How comfortable are you using the reduce() method?

I'm good when it involves adding numbers, less so when it comes to adding objects, but I understand the concept.

How comfortable are you using the sort() method?

Lexicographical sorting is crazy. and this example brought up something that I realized I'm missing... given an array (numbers = [1,2,3], theres numbers.sort() and numbers.sort(function(){}) - so I guess I'm not sure when you have to pass in a function and hen you don't.

In the example provided, I also don't understand why a-b resulting in negative puts a before b, but resulting in positive puts a after b?

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

I understand how to write them based on the lesson on vimeo, but I have no idea how to run them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment