JavaScript features that lend themselves to functional programming

Functions are “high order” – are javascript objects – and can be passed as parameters

“Fat Arrow Functions” easily allow anonymous functions.

A function invokation can be defined immutably with the const keyword

JavaScript provides a “spread notation” when calling a function to allow a variable number of parameters.

JavaScript allows function recursion – a function can call itself

Referential transparency: The function always gives the same return value for the same arguments. In the “functional programming” model, a function cannot depend on any mutable state.

In the “functional programming” model, a function is Side-effect free: In otherwords, a function cannot cause any side effects. Side effects may include I/O (e.g., writing to the console or a log file), modifying a mutable object, reassigning a variable, etc.

Here’s a nice article that also defines what code that is considered “functional programming” should not do as well.

https://opensource.com/article/17/6/functional-javascript

Another nice reference to programming JavaScript “functionally” is the book:

Leave a Comment

Scroll to Top