Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Advanced JavaScript

You're reading from   Advanced JavaScript Speed up web development with the powerful features and benefits of JavaScript

Arrow left icon
Product type Book
Published in Jan 2019
Publisher
ISBN-13 9781789800104
Pages 330 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Zachary Shute Zachary Shute
Author Profile Icon Zachary Shute
Zachary Shute
Arrow right icon
View More author details
Toc

Function Composition


Function composition is the final key to understanding functional programming. Function composition takes many of the concepts learned in this chapter and nicely wraps them in the core of functional programming. The widely used definition of function composition is that function composition is a mathematical concept that allows you to combine multiple functions to create a new function. This definition tells us what function composition is, but doesn't really give us any sense of how to compose functions or why we need to use it.

As we know from the definition, function composition is the act of combining functions to create a new one. What does this mean exactly? In mathematics, we often see functions composed like so: f(g(x)). If this is not familiar to you, in the expression f(g(x)), we pass the variable x into the function g and then pass the result of g(x) into the function f. The expression f(g(x)) is evaluated from the inside out, from right to left, in the order...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime