All about functions
Let’s start with a short review of functions in JavaScript and their relationship to FP concepts. We will begin with something that we mainly mentioned in the Functions as first-class objects section of Chapter 1, Becoming Functional, and again in a couple of places in Chapter 2, Thinking Functionally, and then go on to several considerations about their usage in actual coding. In particular, we’ll be looking at the following:
- Some basic concepts about lambda calculus, which is the theoretical basis for FP
- Arrow functions, which are the most direct translation of lambda calculus into JavaScript
- Using functions as first-class objects, a key concept in FP
Of lambdas and functions
In lambda calculus terms, a function can look like λx.2*x. The understanding is that the variable after the λ character (the Greek letter lambda in lowercase) is the parameter for the function, and the expression after the dot is where you...