diff --git a/files/en-us/web/javascript/reference/global_objects/array/reduceright/index.html b/files/en-us/web/javascript/reference/global_objects/array/reduceright/index.html index c19ac54e1fba685..11e5880f8868e72 100644 --- a/files/en-us/web/javascript/reference/global_objects/array/reduceright/index.html +++ b/files/en-us/web/javascript/reference/global_objects/array/reduceright/index.html @@ -324,23 +324,16 @@
redu
console.log(left); // "12345"
console.log(right); // "54321"
-Defining Composible Function
-
-The concept of compose function is simple it combines n functions. It’s a flowing
- right-to-left, calling each function with the output of the last one.
-
-/**
- * Function Composition is way in which result of one function can
- * be passed to another and so on.
- *
- * h(x) = f(g(x))
- *
- * Function execution happens right to left
- *
- * https://en.wikipedia.org/wiki/Function_composition
- */
-
-const compose = (...args) => (value) => args.reduceRight((acc, fn) => fn(acc), value)
+Defining composable functions
+
+Function composition is a mechanism for combining functions, in which the
+output of each function is passed into the next one, and the output of the last
+function is the final result. In this example we use reduceRight()
+to implement function composition.
+
+See also Function composition on Wikipedia.
+
+
const compose = (...args) => (value) => args.reduceRight((acc, fn) => fn(acc), value)
// Increment passed number
const inc = (n) => n + 1