Functional Programming – Definitions

First-Class functions:
Functions are “first-class” objects.
The “first-class” means that something has a value:
var name = "Leo";

“First-Class Functions” mean that you can STORE functions into a variable:
var subName = function(a,b){ return name + a + b };

In JS functions are Higher-order and First-Class

Higher-order functions:
Functions are objects, Functions are not just methods.
Basically, it means that functions are not just methods, they can be passed around as data, can appear as parameters to other functions (these are usually known as callbacks) and can be returned from other functions (which leads to things like composable functions and the like). As I’ve said many times in past posts: functions are objects.

Pure functions:
Are pure because each time those are called a new array is created and return, the existing array is not modified. Pure functions are another way to say NO mutating state.

An immutable object is an object that can’t be modified after it’s created. Conversely, a mutable object is any object which can be modified after it’s created.
Immutability is a central concept of functional programming because, without it, the data flow in your program is lossy.

A recursive function is a function that quite simply calls itself. Recursion (use it instead for or while loops)

Since Javascript has higher-order functions we can call functions with some of its arguments pre-filled

Functions that are expensive to run can be optimised with memoisation. This involves using a closure to cache the results of previous calls to the function

Function composition:
is the process of combining two or more functions in order to produce a new function or perform some computation.

Reactive Functional Programming:
Reactive Programming is a paradigm where “asynchronous data streams” can be used almost everywhere. Everything is a stream.

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *