Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda