- First-class functions - functions are objects themselves
- Anonymous functions - functions can be unnamed and nested
- Closures - functions that refer to independent variables, that were created in other scope
- Recursion - function can call itself
By the way, there are some significant differences:
Ramda.js has some distinguishing features:
- It’s designed in pure functional style, with immutability and side-effects free functions, that helps you to write simple and effective code.
- Parameters in functions have the same order, with key params at first and data at last
- Ramda.js functions are automatically curried, that allows you to easily build new functions from old ones
To show examples of Ramda.js using, i will use io.js 3.2 and Babel, so let’s create new .js file:
Ramda.js API has some general use functions:
Like the Underscore and Lodash, Ramda has collection helper functions:
And object helpers too:
But key point of Ramda.js is functions. Ramda allows you to easily compose multiple functions in different orders:
Another power of Ramda is currying. Currying is the process of translating evaluation of function that takes multiple parameters in evaluating a sequence of functions, each with one argument.
Pattern matching is also available through R.cond. That allows you to check sequence of conditions to match different patterns: