1

I have array of objects:

var aoo = [{},{},{},....{},{},{}];

I need a optimized function to get element from n to m elements. Example:

var getEl = function(from,to){ ... return array )

How do it in best optimized way?

asked May 16, 2012 at 16:19

2 Answers 2

6

You're looking for the slice method:

var arr = aoo.slice(from, to);
T.J. Crowder
1.1m201 gold badges2k silver badges2k bronze badges
answered May 16, 2012 at 16:22
Sign up to request clarification or add additional context in comments.

Comments

4

I think your looking for the slice function. Something like

var getEl = myArray.slice(from, to)
answered May 16, 2012 at 16:22

1 Comment

8 seconds in it! You get a +1 from me ;)

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.