What is Functional Programming?

Functional programming revolves around the idea that a program is made of a set of functions and they follow certain rules. It is a programming paradigm, meaning that it is a way of thinking about software construction based on some fundamental, defining principles. Popular programming languages that support functional programming techniques are Python , Ruby and many others. Functional programming is a clean, robust alternative to the more typical procedural style of programming. The main concept of Functional programming is the idea of pure functions. Those are functions that take some input, operate on it and return an output without modifying any variables our state outside of the scope of the function. Every function that reaches out for the Document Object Model or uses variables that are not in it's scope is therefore considered impure and does not step up to the standards of functional programming.

Is Javascript a Functional Programming Language?

Although Javascript is not widely known or used as a functional language , it does have some functional elements. If you define functional language as the language that supports first class functions and lambdas, then yes, JavaScript is a functional language . If you also consider the factors like support for immutability, algebraic data types, pattern matching, partial application etc, then no, JavaScript is not a functional language . Moreover, JavaScript has got a control flow and is conceptualized as a imperative language . From its design objective, it is clearly not considered as a functional language.

Why Functional Programming?

  1. Its pure function, provides confidence of not changing things outside of its scope.

  2. Its reduces the complexity, need not to worry about how it is doing it, focus will be only on what it is doing.

  3. Ease of testing, because it does not depend on state of the application and result verification also will be easy.

  4. It makes the code more readable.

  5. Functional programming makes code easier to understand.