_.each is for looping and _.find returns the first match:
function dropExtraneousViews(viewsToKeep) {
var temporaryViews = new Array();
_.each(app.views, function(name,view) {
if (view.indexOf(tempMoniker) == 0) {
temporaryViews.push(view);
}
});
_.each(temporaryViews, function(view) {
var match = _.find(viewsToKeep, function(keeper) {
return keeper == view;
});
if (match == undefined) {
delete app.views[view];
}
});
}
No comments:
Post a Comment