Saturday, 7 September 2013

get all elements after a certain index in javascript

get all elements after a certain index in javascript

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.

No comments:

Post a Comment