JSFiddle - React, Tailwind, and code Playground

by asuma igarashi

JavaScript

let dimCollection = new Backbone.Collection([{modelId: 1}, {modelId: 2}, {modelId: 3}, {modelId: 4}]);
let tableCollection = new Backbone.Collection([{modelId: 1}, {modelId: 2}]);

dimCollection.some(dimModel => {
    const findCond = {modelId: dimModel.get('modelId')};
    if (tableCollection.findWhere(findCond)) {
        // continue
        return false;
    }
    dimCollection.remove(dimModel);
});
alert(JSON.stringify(dimCollection.toJSON()));