6 fundamental terms in functional JavaScript
Let’s talk about what are lambdas, first-class functions, higher-order functions, unary functions, currying and pure functions.
If you are not clear on the difference between imperative and declarative programming, please consider reading my post: Imperative vs Declarative programming in JavaScript
What is a lambda => arrow function?
Lambdas (λ) are better known in JavaScript as arrow functions:
// this is your regular named function in JavaScript
function namedFunction (a, b) {
return a + b;
}// this is a lambda, i.e. an arrow function
const lambda = (a, b) => a + b;
The term lambda originates from lambda calculus, a formal system of mathematical logic. Lambda calculus is of course Turing complete and as such it represents a universal model of computation able to build any Turing machine.
Lambda expressions are the cornerstone of functional programming. If it helps you, just think of them as a new shorter syntax for your functions. However, be careful about using them in your objects or classes as they use lexical this
.