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

202
Views
El método de reducción de matriz está sobrescribiendo el primer elemento

a continuación está mi función que tiene método de reducción

 getFilters(gridFilters, columnList){ const filtersArray = []; let filterObject = {}; gridFilters.forEach((ele, i, arr) => { filtersArray.push(...arr[i].filters); }); const _filArr = filtersArray.reduce((acc, {field, operator, value}) => { filterObject['columnName'] = field; filterObject['filterValue1'] = value; filterObject['filterOperator1'] = operator; filterObject['filterValue2'] = ''; filterObject['filterOperator2'] = ''; columnList.push(filterObject); return acc; }, {}); return columnList;

Aquí, filtersArray tendrá 2 elementos de matriz como '

 Array(2) 0: field: "objectType" operator: "contains" value: "lic" [[Prototype]]: Object 1: field: "attributeDisplayName" operator: "contains" value: "date" [[Prototype]]: Object length: 2 [[Prototype]]: Array(0)

Pero después de enviar los valores a la matriz columnList , veo que el segundo objeto (que tiene el attributeDisplayName ) viene para ambos valores. Básicamente, el primer objeto (que tiene objectType ) se sobrescribe con el segundo objeto en la matriz.

Así es como se columnList la lista de columnas

 Array(2) 0: columnName: "attributeDisplayName" filterOperator1: "contains" filterOperator2: "" filterValue1: "date" filterValue2: "" [[Prototype]]: Object 1: columnName: "attributeDisplayName" filterOperator1: "contains" filterOperator2: "" filterValue1: "date" filterValue2: "" [[Prototype]]: Object length: 2 [[Prototype]]: Array(0)

¿Puede alguien sugerir qué estoy haciendo mal aquí? Gracias

about 4 years ago · Juan Pablo Isaza
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!