Skip to content

Files

Latest commit

 

History

History
19 lines (13 loc) · 391 Bytes

no-length-as-slice-end.md

File metadata and controls

19 lines (13 loc) · 391 Bytes

Pattern: Unnecessary length argument in slice()

Issue: -

Description

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.

Examples

Example of incorrect code:

foo.slice(1, foo.length);

Example of correct code:

foo.slice(1);