I have an array setup like the following:
services = ['times', 'food', 'messages', 'share']
And I would like to be able to pass into services ‘times’ and have it return the next position in the array i.e. ‘food’
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is JS, but also valid in CoffeeScript. Note, though, that if used outside of CofeeScript, it’s an ECMA5 addition, so won’t work in older browsers (EDIT – as the comment says, this of course means IE <= 8).