In this module, we've learned the attitude of JavaScript towards functions: it loves them!
We've seen multiple ways of defining them:
- function declarations
- function expressions
- arrow function expressions
Then we saw JavaScript pass functions around in the collection-processing
methods like map
, reduce
, filter
, etc. These lessons demonstrated that
we weren't using functions and their status as first-class data to their full
potential and that we could level-up our skills!
We then learned a new paradigm that embraces JavaScript's love of functions:
record-oriented programming. While we started by writing functions in a way
that was familiar, we learned to change our approach and pass an execution
context when we called the function. We did so explicitly using call
,
apply
, and bind
. We also saw how JavaScript implictly sets context
during function invocation. Lastly, we saw how the this
keyword was our
magic hook for grabbing the context from within a function.
Yet life with this
can be tricky, so we learned how to defend against lost-context
bugs and then stretched ourselves to build our own function-based
framework.
We've come a long way in this module and a thorough celebration is in order.
Hopefully, you've felt your mind stretch just a bit as you've come to
understand JavaScript's love of functions. We hope you've come to love
functions just a little bit more, too! Whatever's next in your study of
JavaScript, understanding JavaScript's love of and support for using,
passing, call
-ing, bind
-ing and using this
is a crucial foundation for
growing amazing JavaScript programs. Congratulations!