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

144
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

Another simple approach would be

this.tierArray = [...this.tierArray.filter(tier => tier !== value.name)];
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