Now, if you’d like to learn more about what exactly the
For those of you that don’t care too much about the nitty-gritty side of things, in addition to allowing us to implement new & cool features, it also means that we are now able to make use of new & alternative syntax(es). An example being what’s commonly referred to as an ‘arrow_function‘,
in basic terms this is where you no longer need to use the word ‘function‘ to define a function. Instead, if you’re familiar with lambda functions then you’re probably already familiar with the syntax, in very basic terms it’s just a much shorter & in my opinion easier way to implement a function.
Okay, so we know about ES6, but what is ‘Functional Programming‘?
This is a good question & if you’ve asked yourself this question, I’m glad to be the one to introduce you to the programming paradigm known as functional programming. In a nutshell, functional programming is a more
declarative way to write your code. Furthermore, functional programming requires you to follow a certain set of rules or principles.
There’s many a debate as to what these principles are & how religiously they must be followed in order for some code to be classified as an implementation of functional programming. My personal guideline is that you make use of pure functions, currying, immutability, etc, however, I don’t like to be too strict with these guidelines.
You now may be wondering as to why I would say how I don’t like to be too strict, the short & simple answer is that I like to implement my solutions in the cleanest, most concise & simplistic ways possible. Personally I’m a religious believer in the KISS programming principle(s), if you can make it more simplistic, why not?
- Immutability – Preventing data from changing, or in a more formal phrase ‘data whose state cannot be modified after it’s been created‘.
- Currying – A function that takes one argument & returns another function that takes one argument.
- Pure Functions – A function that will always return the same value for the same arguments, i.e. a function that adds 2 to some integer, furthermore the function has no side effects.
- First Class Functions – Essentially you may pass functions as arguments to other functions.
Within the example I’ve provided, the code will simply take some dictionary, aka an array of strings, and some word, aka a single string, then find all anagrams of the provided word within the dictionary.