What is functional programming?

Functional programming is a programming paradigm where the focus is on changing data through small expressions that don’t have side effects.

In other words, when multiples calls to any function occur with the same arguments, the result will always be the same. This is because the functions don’t depend on a local or global state, which produces different results depending on the state.

Functional programming is based on:

First class functions

Functions that can be treated like regular variables. Such functions can be passed as arguments to other functions, can be returned by other functions, and can be assigned as values to a variable.

svg viewer
var foo = function(){
return "Edpressos are fun!";
}
function Edpresso(greeting){
console.log("Educative's " + greeting());
}
Edpresso(foo);

Higher order functions

Functions that return other functions are called higher order functions.

svg viewer

Data immutability

Data cannot be modified after creation in functional programming. So for example, an object ‘n’ with the value of 5 will always have the value of 5.

Lazy evaluation

The evaluation of an expression in functional programming is delayed until the value is needed.

// Not lazy
var sum = 1 + 1;
// Evaluates 1 + 1 immediately
// Lazy
const lazySum = () => 1 + 1;
// Evaluates 1 + 1 upon invocation

Recursion

Most functional code is written with recursion instead of for-loops. In fact, some functional languages don’t even support for-loops!

Pure functions

Pure functions are functions whose return values are solely determined by the function’s inputs.

recursion
recursion
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved