0

Please can anybody tell me what (...fns),initalVal ,fn and Val mean

const compose = (...fns) => (initialVal) => fns.reduceRight((val, fn) => fn(val), initialVal);

14th May 2022, 3:41 AM
steve Purpose
steve  Purpose - avatar
8 Respuestas
+ 1
Ok thanks a lot..let me go through it
14th May 2022, 4:27 AM
steve Purpose
steve  Purpose - avatar
+ 1
Ok thanks.Was able to get the meanings although explanation was still sketchy, they didn't give any examples before moving to pipeline..I'll just keep searching for examples where it was applied.
14th May 2022, 5:14 AM
steve Purpose
steve  Purpose - avatar
0
Where did you get that example?
14th May 2022, 3:48 AM
Chris Coder
Chris Coder - avatar
0
I actually understood the whole concept previously and even tried it on 2 functions but it was reading left to right like pipe. Now from these links you sent,I want to reference this from freecodecamp compose = (fn1, fn2) => value => fn2(fn1(value) What does value stand for? is it an argument?
14th May 2022, 4:01 AM
steve Purpose
steve  Purpose - avatar
0
This below is more like the pipe analogy const Drive=function(car){ return ` i cruised through the Empire city with the ${car}`} const Park=function(car){ return `then came back home to my four car garage to drop the keys to the ${car}`} console.log(Drive(Park("ferrari")))
14th May 2022, 4:06 AM
steve Purpose
steve  Purpose - avatar
0
Sorry I thought the links explained well what the functions in your question were. Please disregard if it confused you more. This shall explain the exact reduceright function. https://gideonpyzer.dev/blog/2017/01/02/javascript-function-composition-and-pipelines/
14th May 2022, 4:22 AM
Chris Coder
Chris Coder - avatar
- 1
It's on virtually every functional programming compose and pipe method in JavaScript online
14th May 2022, 3:52 AM
steve Purpose
steve  Purpose - avatar