Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
How to remove an array from a nested array in JavaScript?

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

var arr = [
    [1, 2],
    [2, 3],
    [3, 4]
]
console.log('Before =>', arr);
arr.splice(1, 1); // .splice(index, 1);
console.log('After=>', arr);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!