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

191
Vistas
Best way to restructure my Duplication Removal function

So I have a VueJS table, and sometimes I push double values to this table, I've created the following to remove the doubles before they get pushed onto the table, but I feel I've gone about it wrong, my data does not flow and it's probably too long. Perhaps the filterin should happen right after I declare my Consts? I'd be happy to hear suggestions and examples on how best this can be achieved in my JS.

methods: {
tableDataToDataValueCells(participant) {
  const fields = [
    { fieldName: 'companyNames', fieldClass: 'CompanyName' },
    { fieldName: 'aliases', fieldClass: 'Alias' },
    { fieldName: 'addresses', fieldClass: 'Address' },
    { fieldName: 'phones', fieldClass: 'Phone' },
    { fieldName: 'emails', fieldClass: 'Email' },
    { fieldName: 'birthdates', fieldClass: 'Birthdate' },
    { fieldName: 'customerNumbers', fieldClass: 'CustomerNumber' },
    { fieldName: 'ibans', fieldClass: 'BankAccount' },
  ];
  let result = [];
  

  fields.forEach(field => {
    if (participant[field.fieldName].length > 0) {
      result.push({
        attributeName: field.fieldName,
        columnName: I18n.t(`ccenter.participant.table.${snakeCase(field.fieldName)}`),
        columnValues: participant[field.fieldName],
        fieldClass: field.fieldClass,
      })
    }
  });
  // return result;

  // filter out duplicates here
  let array = result;
  let unique = [];
    data.forEach(element => {
      if (!unique.includes(element)) {
        unique.push(element)
      }
    });
    return array;
    }
  }
};
about 4 years ago · Juan Pablo Isaza
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