Is there an equivalent for ruby’s array[n..m] in JavaScript?
For example:
>> a = ['a','b','c','d','e','f','g']
>> a[0..2]
=> ['a','b','c']
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.
Use the
array.slice(begin [, end])function.The last index is non-inclusive; to mimic ruby’s behavior you have to increment the
endvalue. So I guessslicebehaves more likea[m...n]in ruby.