Kimberlee Johnson

💡 JavaScript fundamentals, or, everything’s a function

I learned the basics of functions and some handy use cases, like building new Objects of a type (constructors) or taking in other functions as parameters (higher order functions and callbacks); new array methods for manipulating data sets; and how to create Classes and define a closure.

Dorothy Parker is known less for her work on the original ‘A Star is Born’ screenplay and more for her unbeatable quips e.g., “This wasn’t just plain terrible, this was fancy terrible, with raisins in it.”

Every day learning JavaScript feels a bit like this. Once we get the basics, everything iss “...not just a plain function, this is a fancy function, with callbacks on it.”

A function is a set of statements that performs a task, like calculating a value, that can be repeated. They’re foundational to all the interactions we might have on a website.

We started out covering basics, like a few different ways to write and format functions, including with arrows (=> fancy). We also covered arrays, derived from functions, and a few of their methods. Methods are, unsurprisingly, just fancy functions attached to Objects that can do useful things like .push() new items into a data set. We manipulated array indices to find unique items, in our use case specific interns or cars.

We got to work with 5k runners instead in our next data set, which I’ve been ready for since St. Patrick’s day. We used that data to apply what we learned about closures, the invisible glue that lets child (embedded) functions reference values in parent functions, and higher order functions that can take in other functions called callbacks as parameters. We also covered more complex array methods like .reduce() that returns a value from the array, or .map() that creates a new array.

After adding that complexity, we deep-dived on the this keyword and how it points functions to the right context to find a value. We covered constructor functions for creating new Objects of a certain type a little less manually, and their prototypes, which we use to add methods to each new Object. We used those concepts to build different Heroes and Villains in a very basic game.

Of course, we learned a much easier way to create new Objects immediately the next day with Classes, which embed constructor functions and use keywords like ‘extends’ and super() to ensure attributes and methods can be inherited by a new Class. We refactored the previous day’s code to be more palatable with these new tools.

While tiring, learning something the hard way first can be worthwhile, so that we then understand why the shortcuts under the hood work, or, in other words, what the fancy raisins are doing in there in the first place.

How I’ll apply what I learned to my blog

  • That’s coming up next week!

Advice for other students

  • If you're going to be a remote learner, be deliberate about getting out of the house to spend time with friends and family. When scary, sad, or meh things happen, you likely won’t have the day-to-day other people time that you have at an office to take your mind off things.
  • Know yourself and where you get your energy. I skew very introvert, so that makes an online program a lot easier for me to handle. If I got my energy almost exclusively from being around other people, I’d be in trouble.

Life outside of learning

  • My fiction class is still delightful. This week a student wrote a fantastical, beautiful story that was a metaphor for growing up in the closet. I feel privileged to get to hear these stories.
  • I went to a contemporary dance performance. I want to be the kind of person who enjoys contemporary dance, I do, but I struggle so hard every time. If you have resources for learning how to enjoy it, point them my way!
  • Am reading: “Dumplin’”, FINALLY. I was on the library waitlist for four months after the movie came out. But, this seems to be the rare case where I prefer the movie to the book. Boys matter wayyyy more and Dolly Parton is only mentioned once every 30-40 pages instead of every 3-4 minutes.