Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda