Skip to content

Remove-Redundant-Slice-Index

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

Sourcery rule id: remove-redundant-slice-index

Section titled “Sourcery rule id: remove-redundant-slice-index”

Remove a redundant index from the array .slice() method.

const toEnd = numbers.slice(3, numbers.length)
const toEnd = numbers.slice(3)

Parameters in the array prototype .slice(start, end) method are optional, and by convention you should only use the necessary ones, to simplify readability. The end is not necessary if you want to slice to the end of the array. The start is additionally not necessary if you want to slice from the start of the array.