Im just looking for a good way to do this:
I have 2 arrays:
var allItems = [
{'id' : '1', 'title' : 'Title 1' },
{'id' : '2', 'title' : 'Title 2' },
{'id' : '3', 'title' : 'Title 3' },
{'id' : '4', 'title' : 'Title 4' },
{'id' : '5', 'title' : 'Title 5'},
{'id' : '6', 'title' : 'Title 6' }
];
var idsToExtract = ['1', '3', '6'];
I am looking for a result with two arrays that look like this:
var array1 = [
{'id' : '1', 'title' : 'Title 1' },
{'id' : '3', 'title' : 'Title 3' },
{'id' : '6', 'title' : 'Title 6'}
];
var array2 = [
{'id' : '2', 'title' : 'Title 2' },
{'id' : '4', 'title' : 'Title 4' },
{'id' : '5', 'title' : 'Title 5'}
];
I am ONLY using native JS ( ES2015 ) array methods.( map/filter etc).
NO jquery/underscore etc.
Thanks!