Reputation: 235
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?
Upvotes: 1
Views: 72
Reputation: 23250
You're looking for the slice
method:
var arr = aoo.slice(from, to);
Upvotes: 6
Reputation: 25435
I think your looking for the slice function. Something like
var getEl = myArray.slice(from, to)
Upvotes: 4