Mivaweb Mivaweb - 1 year ago 74
AngularJS Question

Remove elements from array above an index AngularJS

Is there a quick helper for removing elements from an array above a certain index in AngularJS?

For instance:

You have an array with 5 elements:


I want to remove all elements above index 2:



Answer Source

Yes, there is:

array.slice(start, end)

In your case, something like this:

array.slice(0, -2)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download