Reputation: 11686
I'm trying to remove the last 100 models from a collection. Is there an easy way to just slice those off and remove/delete them or do I need to iterate through them and remove them?
Right now i'm doing something like this: (in the collection & coffeescript)
for i in [@[email protected]]
@remove @models[i]
Answer: (in the collection & coffeescript)
@remove @slice(-100)
Upvotes: 1
Views: 122
Reputation: 55740
Not sure about coffeescript
, but you can use a combination of slice and remove
collection.remove(collection.slice(start,end));
Upvotes: 2