There have been quite a few “a-ha!” moments while reading, including:
- Just how useful property access using the bracket notation is:
- Not just what hoisting is, but when it works:
- That there’s an
argumentsobject associated with each function. The obvious benefit is that it can be used to accept any number of function parameters:
However, I got to chapter 3 and ran into a little confusion regarding
.bind(). Realizing I needed a this keyword refresher, I re-read these articles by Richard Bovell and David Flanagan:
this refers to the execution context, not the current object, sometimes we have to use a function like .apply() and .call() to set the scope explicitly. They both assign a different this object when calling an existing function and the only difference is that
.call() accepts an any number of arguments
.apply() accepts an array of arguments.
bind() function returns a new function with the this value of the new function set to the provided argument. I need to remember not to pass in this as a parameter or cache it in a variable to use inside a nested function, but to use
Closures are when an inner function has access to the outer functions parameters. For some reason, it wasn’t immediately obvious that the outer function returned another function, not a variable:
A coworker coined a term for my literary adventures:
wordhole (n): A common phenomenon occurring while reading technical literature, in which the reader is sucked into a continual search for meaning that only provides new depths of confusion.
It’s been a busy summer, but I’m glad to be back learning, reading, and programming at the coffees shop on my weekend mornings.