Day 2
Day 2 was just as intense as Day 1. This is the last day of reviewing the prework and our task is to finish the Underbar assignment. Underbar is basically all the default functions for iterating through arrays that we usually take for granted. Examples: .map, .each, .reduce, .reject, .every, .once, .any, etc. I partnered up with a new partner for this one. It was difficult at first mainly because I we were so similar. We both were somewhat stubborn in our approaches. Often we would both have an idea of how a function should be created, we couldn't verbalize it that well and we'd end up having to just take the keyboard to show how to do it. This is obviously not the point of pair programming. Over the course of our pairing, we worked out better solutions. I got better at writing sudo code to explain the high level ideas. We gained more trust in each other. And we started to come to agreement on smaller pieces of the function as opposed to how the entire thing should written.
Next we dove into wtf 'this' means in Javascript. Honestly it was pretty confusing at first. Javascript seems like a language that was not thought through very well. Apparently as the story goes, an engineer at Netscape made the language in a week. When he tried to push it to the new Netscape release, one of the heads there said it needed to look more like Java to get widespread adoption. So they added a bunch of Java like syntax and voila, Javascript was born out of Oak. 'this' in Javascript basically refers to the object left of the dot AT CALL TIME of the function referencing 'this'. It is a way to refer to the object referencing whatever you are calling. But there is a bunch of added complexity and nuance. If you just call console.log(this) then it would return window because there is nothing left of the dot.
Underbar was great practice in how to create basic iterations and callbacks. I had a tendency to want to apply a for loop to everything but my pair helped me to stretch my abilities more to use the functions we had created on each other. For instance, using _.reduce to solve _.every, etc.
Lastly, we went over the prototype chain in Javascript which was (like everything in Javascript) pretty damn confusing. I was used to the really simple inheritance that goes in Ruby so looking at the prototype chain in Javascript was a mess. A prototype is an object to which some other object delegates its failed lookups. This means that we called a brand new property on an object that didn't have that property, it would delegate that call to it's prototype. Simple in concept, but the implementation gets a little fuzzy. For instance, the Array.prototype doesn't contain the .length method, the .length method is created when a new array is constructed. As an example of an object, if we set Object.prototype.GAH = 7, then we could call .GAH on any object that we create and it would return 7.









