function getComposition(func1, func2) {
}
getComposition(Math.sin, Math.asin)(x)
Math.sin
а func2 это Math.asin
. x таким и останется, то есть его и передадут x.func1(func2(x))
function getComposition(func1, func2) {
return function(param) {
return func1(func2(param));
}
}
let result = getComposition(Math.sin, Math.asin)(x);
console.log(result);
const getComposition = (func1, func2) => param => func1(func2(param));
let result = getComposition(Math.sin, Math.asin)(x);
console.log(result);
const composition = (...funcs) => initialVal => funcs.reduceRight((v, f) => f(v), initialVal);
composition(v => v ** 3, v => v + 1, v => v / 2, v => v << 4)(1) // 729
composition(v => v.join('-'), v => [...v], v => v.slice(0, 5))('hello, world!!') // 'h-e-l-l-o'
composition(Object.keys)([ 69, 187, 666 ]) // ['0', '1', '2']