Posts

Showing posts from June 23, 2019

How to merge and return new array from object in es6

Image
11 1 Suppose there are two objects. const a = [ { id: '1-1-1', name: 'a111' }, { id: '1-1-2', name: 'a112' }, { id: '1-2-1', name: 'a121' }, { id: '1-2-2', name: 'a122' }, { id: '2-1-1', name: 'a211' }, { id: '2-1-2', name: 'a212' } ] const b = ['1-1', '1-2', '2-1'] and the result { '1-1':[ { id: '1-1-1', name: 'a111' }, { id: '1-1-2', name: 'a112' }, ], '1-2':[ { id: '1-2-1', name: 'a121' }, { id: '1-2-2', name: 'a122' }, ], '2-1':[ { id: '2-1-1', name: 'a211' }, { id: ...