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

154
Visualizações
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 à 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