UI Development

Functional Programming Vs Object Oriented Programming in Javascript

Hi Techies,

Are you ready to embark on the functional programming journey? You’ve come to the right place. Programming languages are a fundamental tool in a every programmer’s life and important to almost every activity related to programming. Today, we will looking into the key differences, head to head comparison and conclusions between Functional Programming and Object-Oriented Programming.

Objected-Oriented Programming (OOP) and Functional Programming (FP) are the two predominant patterns in JavaScript, mainly considered the two pillars of JavaScript. Both patterns have their own identity In JavaScript world.

First, we will start with the overview of Object-Oriented Programming in JavaScript In this blog i will cover major part of FP and will go deeper into the concept of Functional Programming which is something hard because nobody is talking about how to do it, because it can be a kind of subjective.

Object-Oriented programming is achieved in JavaScript through the use of prototypal inheritance. OOP use objects without classes, prototype delegation (objects linking to other objects).Object-Oriented programming works upon the idea of inheritance.Let see small example

Example: Create ‘Person’ object which has a name and a greeting in OOP way.



but the same approach for the functional programming is different from OOP approach as the stresses simple functions that provide one piece of functionality.

You must be thinking by seeing the above code why we have create the Person Object like this in function Programming. No need to worry let start the actually discussion and implementation of FP.


We will learn about the benefits of learning functional programming languages along with examples of how tech giants have incorporated functional programming into their software development.

Introduction to Functional Programming:

What is a functional Programming in the first place and Why do we need to know it? The answer is pretty simple. The reality is that there isn’t any fixed definition of functional programming.

Functional Programming (often abbreviated as FP) is one of the type of program pattern that helps the process of building application by using of pure functions, avoiding shared state, mutable data, and side-effects.

Core Concepts of Functional Programming:

In order to understand the functional programming in practice then you have to understand the each and individual core concept in functional programming.

let start one by one:

Declarative vs Imperative :

Functional programming is a declarative pattern, meaning that the program logic is expressed without explicitly describing the flow control.imperative programs spend lines of code describing the specific steps used to achieve the desired results — the flow control

Declarative programs remove the flow control process, and instead spend lines of code describing the data flow.


This imperative mapping takes an array of numbers and returns a new array with each number multiplied by 2:

const doubleMap = numbers => {
  const doubled = [];
  for (let i = 0; i < numbers.length; i++) {
    doubled.push(numbers[i] * 2);
  return doubled;
console.log(doubleMap([2, 3, 4])); // [4, 6, 8]
This declarative mapping does the same thing, but remove the flow control away using the function utility, which allows you to more clearly express the flow of data:

const doubleMap = numbers => numbers.map(n => n * 2);
console.log(doubleMap([2, 3, 4]));
// [4,6,8]


About The Author