I have a simple array with numbers let array = [1,2,3,4,5,6,7,8,9]
and I want to take a "section" of numbers to the end of the array (9). The section is decided by an index:
For example:
let array = [1,2,3,4,5,6,7,8,9]
index = 3;
newArray = [7,8,9] // resultado
let array = [2,100,24,9]
index = 2;
newArray = [24,9] // resultado
What is the most direct way to do it? I start doing slice, splice, for loops etc and it gets so complicated that I get blocked... there must be a more direct way.
You can use
Array.slice()
like this: