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

143
Vistas
Using Array.pop and Array.indexOf togther are not working

I'm trying to use Array.pop(Array.indexOf(value)) but it delete the last element in the index even if the value of that index is not same as I set it, can you please help me

  CheckBoxHandler1(e) {
    console.log(e.target.checked, e.target.name);
    let temp = [...this.state.boxes];
    e.target.checked === true
      ? temp.push(e.target.name)
      : temp.pop(temp.indexOf(e.target.name));
    this.setState({
      boxes: temp,
    });
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It happens because Array.prototype.pop() always remove the last element of the array.

If you want to remove one specific element, you need to do the following:

temp.splice(temp.indexOf(e.target.name), 1);
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