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

160
Vistas
Object not being removed from array

I am trying to use array.splice to remove an object from my array, but my object position in the array is -1 so its not being removed. I think its because I am creating a new object every time, so the two object are not the same. Here is my code.

let selectedCurrency = new Currency(null, null, null, symbol, currency_code, false, false, currency_description, null);

    if (event.checked) {

      this.companyCurrencies.push(selectedCurrency);

    } else {
      console.log("original array: ",this.companyCurrencies);

      console.log("selected currency: ",selectedCurrency);

      let index = this.companyCurrencies.indexOf(selectedCurrency);

      if (index === -1) {
        return;
      }

      this.companyCurrencies.splice(index, 1);
      console.log("array after spliced: ",this.companyCurrencies);
    }

I am not sure how to get around this issue, any help would be much appreciated thanks.

over 4 years ago · Santiago Trujillo
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