JS Coding Questions Logo
JS Coding Questions
#450💼 Interview💻 Code

What is Function Composition?

Advertisement

728x90

It is an approach where the result of one function is passed on to the next function, which is passed to another until the final function is executed for the final result.

javascript
1//example
2
3const double = (x) => x * 2;
4
5const square = (x) => x * x;
6
7var output1 = double(2);
8
9var output2 = square(output1);
10
11console.log(output2);
12
13var output_final = square(double(2));
14
15console.log(output_final);

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 21

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
450of476