Try to search your question here, if you can't find : Ask Any Question Now ?

Create variable of arguments type

HomeCategory: stackoverflowCreate variable of arguments type
Avatarkundan asked 5 months ago

I’m trying to make middleware function lets call it debug, which should take some parameters, log them and pass to the next function:

const debug = (...args) => {
 return args // will return array, not argument type variable

const compose = (...fns) => (...arg) => (
    (acc, fn) => !acc ? fn(...arg) : fn(acc), null

const f = x => x * x

const g = (a, b) => a + b

const makeMagic = compose(

makeMagic(1, 2)

If I remove debug from composition everything works as expected, as soon as I place it at end, it breaks. Because it takes arguments but returns array.

I tried to rewrite debug this way:

function debug() {
  return arguments

But no way it fails.

1 Answers
Best Answer
AvatarMikhail answered 5 months ago
Your Answer

4 + 2 =

Popular Tags

WP Facebook Auto Publish Powered By :