The slice()
function allows you to “slice” up a list and output a smaller number of items from it.
slice(list, number, number [optional])
list.slice(number, number [optional])
Code language: JavaScript (javascript)
It accepts three arguments:
- The input list.
- A starting index, which is included in the output string (the start index of the input string is
0
). - An ending index, which is optional and excluded from the output string.