Skip to content

unicorn/no-length-as-slice-end Restriction

🛠️ An auto-fix is available for this rule.

What it does

Disallow using length as the end argument of a slice call.

Why is this bad?

Passing length as the end argument of a slice call is unnecessary and can be confusing.

Example

Examples of incorrect code for this rule:

javascript
foo.slice(1, foo.length);

Examples of correct code for this rule:

javascript
foo.slice(1);

References

Released under the MIT License.