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

142
Views
vue, match string in array without IDs and remove if matched

I have a simple array of strings, and I'm calling a function with dropdown actions that will send a string, and if it matches one in the array, I want to remove it from the array but I'm unsure how

I've seen how I could do this with splice, but I don't have IDs on this array, it's only strings. So I literally need to match the string and remove it based on that string match

How can I simply match and remove a string from the array?

here is my code:

new Vue({
      el: "#app",
      props: { 
      },
      data: {
        tierArray:['one', 'two', 'three'],
      },
      methods: {
        removeTierSelection(value){
          console.log('this is what we are removing');
          console.log(value.name); //this prints just the string such as "one" or "two", but without the quotes
        },
      }
    })
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can achieve it by doing this:

 const removeIndex = this.tierArray.findIndex(tier => tier === value.name)
 if (removeIndex === -1) return // means item not found

 this.tierArray.splice(removeIndex, 1)
about 4 years ago · Juan Pablo Isaza Report

0

Another simple approach would be

this.tierArray = [...this.tierArray.filter(tier => tier !== value.name)];
about 4 years ago · Juan Pablo Isaza Report
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!