0
Please can anybody tell me what (...fns),initalVal ,fn and Val mean
const compose = (...fns) => (initialVal) => fns.reduceRight((val, fn) => fn(val), initialVal);
8 Respostas
+ 1
Ok thanks a lot..let me go through it
+ 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.
0
Where did you get that example?
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?
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")))
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/
- 1
It's on virtually every functional programming compose and pipe method in JavaScript online