Is there a way to remove an array from a nested array in JavaScript?
I have the following array:
arr = [
[1, 2],
[2, 3],
[3, 4]
]
and I want to remove the value [2, 3]
from the array so that it results with:
arr = [
[1, 2],
[3, 4]
]
I have already tried the answers on How can I remove a specific item from an array?, but they don't seem to work. I was wondering if there was a fast efficient way of doing this.
Edit:
I already tried using indexOf
and findIndex
, and it does not return the index of an array inside of the array.
arr = [
[1, 2],
[2, 3],
[3, 4]
];
console.log(arr.indexOf([2, 3]));
console.log(arr.findIndex([2, 3]));
This did not work, even though it was suggested in the comments below.
Furthermore, using:
console.log(arr.filter(nested => nested[0] !== 2 || nested[1] !== 3));
will be inefficient as in my code I need to remove large lists, which have hundreds of values, I only provided an example in my question.
Any help would be appreciated.