64
rated 0 times
[
68]
[
4]
/ answers: 1 / hits: 21712
/ 11 Years ago, sun, september 8, 2013, 12:00:00
In python doing this would be as simple as:
mylist = ['red','blue','green','yellow']
print(mylist[1:])
'blue','green','yellow'
When I tried this in JavaScript mylist[0] returned 'red' etc. but when I tried doing something like mylist[1:] in JavaScript it was not correct syntax.
What is a good method of doing this in JavaScript? Basically get all elements after a specified index, and to be specific, I am doing this in Node.js, but I do not think that matters much.
More From » node.js