JavaScript the Fun Part


functional-programming-javascript

five-crucial-fp-concepts


Before diving into those five concepts, here is a quick review for each one.

Note that learning path for these concepts is from top to bottom, in this way

  1. function as first class citizen
  2. closure
  3. currying
  4. partial application
  5. composition

While their dependency flow is from bottom to top. For using composition we should be able to use partial application. For partial application we should be able to use currying; and so on.

  1. composition
  2. partial application
  3. currying
  4. closure
  5. function as first class citizen

function as first class citizen

Not only we are able to use a function as a block of code that can be executed many times, but also we are able to store them as a data, pass it around, or return it from other functions.

closure

Having access to outer scope variables (= data) by reference, even when the outer scope function has been executed, but still we have access to those variables (= data).

currying

Some consecutive nested unary functions. That is it. Their return value is the next function in the series.

partial application

Just using one part of a curry function not all at once.

composition

The act of combining some curried functions (= have been partially applied).

Comping functions from right to left is said compose and from left to right is said pipe.

We will see each one in more details in next posts.


Update: Wed Oct 30 2019 18:48:08 GMT+0330 (Iran Standard Time)