I’m working with a nested array structure that looks like this:
var data = [
[3, 7, 5, 2],
[8, 7, 9, 1],
[2, 4, 9, 3],
[3, 4, 8, 3]
];
I need to filter out sub-arrays that contain a particular value at a specific index. For instance, if I want to exclude all sub-arrays where the element at index 1 equals ‘7’, my expected output would be:
var data = [
[2, 4, 9, 3],
[3, 4, 8, 3]
];
Similarly, filtering out sub-arrays with ‘9’ at index 2 should give me:
var data = [
[3, 7, 5, 2],
[3, 4, 8, 3]
];
What’s the most efficient approach to accomplish this filtering? I’m dealing with large datasets containing over 1000 sub-arrays, so performance is a concern.