DEV Community

Murat-Han
Murat-Han

Posted on

Why is JavaScript a Multi-Paradigm Language?

A paradigm can be defined as an approach to solving a problem. A programming paradigm is a way to solve problems by using a programming language.

As you know, each problem needs a specific approach to its solution. So, we would have a set of paradigms for different sets of problems. As programming languages are a way to solve the problems using the code, they will offer support to these paradigms.

So, any programming language which offers multiple programming paradigms is referred to as a multi-paradigm programming language.Some of the well-known paradigms are mentioned below.

Imperative Programming Paradigm
This is an approach where solutions are designed as sets of a clearly defined sequence of instructions or procedures.
A programming language with this approach will have code with a series of commands specifying what the computer has to do, how it has to do it, when it has to do to it to arrive at the solution. Some of the languages that embrace this are C, C++, C#, Java, Fortran, etc.

Declarative Programming Paradigm
This is an approach where the solution is designed as a set of expectations (what needs to be accomplished) without specifying how it needs to be done.
A programming language with this approach will have code with a series of commands stating desired results without specifying how it needs to be achieved. A good example for this would an SQL query, where the developer states that he needs rows from a specific table, without mentioning how to fetch them.

Object-Oriented Programming Paradigm
This is an approach where the solution is designed around communication between the Objects or Classes, which hold the data and the methods to act upon that data.
A programming language with this approach will have code with a series of operations involving defining classes and interaction among these classes with the help of associated methods. Some of the languages supporting this paradigm are C++, Java, C#, JavaScript, etc.

Functional Programming Paradigm
This is a declarative approach where the solution is designed around applying and composing functions.
A programming language with this approach will have a series of function calls and function compositions, where each function takes an input state and returns consistent output value independent of the program state. Some of the languages supporting this paradigm are Haskell, JavaScript, etc.

source: https://javascript.plainenglish.io/why-is-javascript-a-multi-paradigm-language-3b6cc22fee94

Top comments (0)