What is JavaScript? JavaScript (often shortened to JS) is a lightweight, interpreted, object-oriented language with first-class functions, and is best known as the scripting language for Web pages, but it's used in many non-browser environments as well.
Those first-class functions are what makes functional programming possible in JavaScript. JavaScript is a multi-paradigm language that allows you to freely mix and match object-oriented, procedural, and functional paradigms. Recently there has been a growing trend toward functional programming.
You can write functional programs in many object-oriented languages, such as JavaScript and Python, but these programs aren't truly functional since their constructs don't fully mesh with the framework and rules of functional programming.
Functional programming is based on mathematical functions. Some of the popular functional programming languages include: Lisp, Python, Erlang, Haskell, Clojure, etc. Pure Functional Languages − These types of functional languages support only the functional paradigms. For example − Haskell.
Repeating my own answer to a similar question,
There's no accepted definition of functional programming language.
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.
I'd encourage you to read the following related blog posts (and also the comments below them):
Scala is not a functional language
Erlang is not functional
Reddit discussion on "Erlang is not functional"
I would say that it is a multi-paradigm language.
EDIT: It's multi-paradigm and includes functional constructs.
if you stretch and twist the term "functional programming" to the point of philosophical discussions, this question may be open again. However, then you end up on the level of useful questions like "Is C++ really a programming language"?
The answer to your question on more daily level is "no".
Functional programming means that the program is conceptualized as a evaluation of a function, rather than a control flow. The code is a description of functions, and has no inherent concept of a control flow.
JavaScript has got a control flow and is conceptualized as a imperative language. From its design objective, it is clearly not a functional language.
The term "functional programming" language is so overloaded these days it's almost useless. There are two dominant meanings:
Pick your meaning and then the question is answerable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With