Pattern: Unnecessary length argument in slice()
Issue: -
Using length
as the end argument in slice()
is redundant since slice()
will automatically go to the end of the array or string when no end index is provided.
Example of incorrect code:
foo.slice(1, foo.length);
Example of correct code:
foo.slice(1);