I have the following Javascript arrays:
ARRAY ONE:
[ TextRow { v_id: 3000 },
TextRow { v_id: 3001 },
TextRow { v_id: 3002 } ]
ARRAY TWO:
[ TextRow {
s_id: 'S001',
v_id: 3000,
type: 'control' },
TextRow {
s_id: 'S002',
v_id: 3001,
type: 'mut' },
TextRow {
s_id: 'S003',
v_id: 3001,
type: 'mut' },
TextRow {
s_id: 'S005',
v_id: 3001,
type: 'control' },
TextRow {
s_id: 'S008',
v_id: 3002,
type: 'mut' } ]
For each element in Array One, I would like to get an array of all the elements in Array Two, where the v_id equals the v_id in array one. For example, for v_id = 3001, I would like to get all the elements in array two where the v_id = 3001 in a separate array. However, I am not sure what is the best way to do this task and whether Javascript already has some existing functions that can help me do this. I am asking this since my Array Two has over 1000 elements and I want to know if there is an efficient way to do this instead of just iterating through elements of the array with a nested for loop. Any insights are appreciated.