Functional Programming

Pure Functions

Functions that given the same arguments, they will always produce the same result

higher order functions

.forEach()

.map()

.reduce()

A function that takes in a function as a parameter OR returns a function as its result.

Immutability

A design process that treats your objects state as unchangeable 

lodash.js

_.times(n, [iteratee=_.identity])

A much easier on the eyes for loop where n represents the number of loops

_.times(3, () => {
    //ACTION
})

_.union([arrays])

takes in multiple arrays and will return new array with unique elements

_.union(['Bryan', 'Coco'], ['Lindsey', 'Coco'], ['Coco'])
// ['Bryan', 'Coco', 'Lindsey']

_.intersection([arrays])

takes in multiple arrays and finds values present in all arrays and orders them

_.intersection([2, 1], [2, 3], [1, 3, 2])
// [2]

Finds a random number between two provided numbers

_.random([lower=0], [upper=1])

_.random(0, 333)
// random number between 0 and 333

_.memoize(func)

Optimizes a function by caching its result thus speeding up it's future calls

Copy of underscore.js

By jonmcd

Copy of underscore.js

  • 162