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

> Disallow passing `.length` as the end argument of `.slice()`

Without a second argument, `.slice()` already goes to the end of the array or string. Passing the length of the same value adds nothing.

`--fix` removes the second argument.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/no-length-as-slice-end" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
const rest = items.slice(1, items.length);
```

Not reported:

{/* good */}
```js
const rest = items.slice(1);
const sameSizeAsOther = items.slice(1, other.length);
const allButLast = items.slice(0, items.length - 1);
```
