Arrow Functions and Functional Style

Learn the difference between functional and imperative style programming. Also, find out how to use arrow functions with higher-order functions to create concise code.

The fluency of single-line arrow functions truly shines in the functional style of programming. In this programming style, we use function composition (a series of transformations) to make the code expressive and easier to maintain. Functional style code removes the accidental complexity present in the imperative styleImperativeProgramming of programming.

Imperative style of programming

Let’s explore imperative style programming with a few examples. Suppose we’re given a list of names and asked to create a comma-separated result string with all uppercase names of length five. Try implementing the code using the traditional for loop. It’s a simple problem but not a simple solution. That’s accidental complexity.

Here’s an imperative implementation:

Get hands-on with 1200+ tech skills courses.