Kim Yu
Kim Yu

Reputation: 235

gets elements from array?

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

Answers (2)

Jivings
Jivings

Reputation: 23250

You're looking for the slice method:

var arr = aoo.slice(from, to);

Upvotes: 6

Ash Burlaczenko
Ash Burlaczenko

Reputation: 25435

I think your looking for the slice function. Something like

var getEl = myArray.slice(from, to)

Upvotes: 4

Related Questions