Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!