0
votes

I can't resolve this, please help me.

 const params =
        arguments.length > 3 && arguments[3] !== undefined
          ? arguments[3]
          : null;

The problem is with arguments[3] ESLint says: Use the rest parameters instead of 'arguments'. (prefer-rest-params)

1
yes @epascarello but i don't know how apply it in this case - Jimmy Sorza

1 Answers

1
votes

I don't know what your function looks like where this is happening, but I'll give you an example of the rest params ESLint is talking about with the tiny snippet of code you provided:

function foo( ...args ) {
  console.log( args );
  const params =
          args.length > 3 && args[3] !== undefined
            ? args[3]
            : null;

  console.log( params );
}

foo( 1, 2, 3, 4 );

So ...args is an array of all arguments passed on in the function call that you have not set as a parameter. Any parameter you do have, goes in front of ...args. (Note that you can call this anything you want, such as ...rest.) The reason this might be preferred over arguments is because you cannot use any Array methods on it, while on the rest params you can.