Tutorial by Examples

function transform(fn, arr) { let result = []; for (let el of arr) { result.push(fn(el)); // We push the result of the transformed item to result } return result; } console.log(transform(x => x * 2, [1,2,3,4])); // [2, 4, 6, 8] As you can see, our transform fun...
In general, functions that operate on other functions, either by taking them as arguments or by returning them (or both), are called higher-order functions. A higher-order function is a function that can take another function as an argument. You are using higher-order functions when passing callbac...
This is an example of an implementation of the identity monad in JavaScript, and could serve as a starting point to create other monads. Based on the conference by Douglas Crockford on monads and gonads Using this approach reusing your functions will be easier because of the flexibility this monad...
A basic principle of functional programming is that it avoids changing the application state (statelessness) and variables outside it's scope (immutability). Pure functions are functions that: with a given input, always return the same output they do not rely on any variable outside their scope...

Page 1 of 1