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

130
Views
Eliminar el objeto en su lugar de una matriz: JS

Tengo una matriz de objetos con la siguiente estructura:

 const timeOptions = [ { key: "all", value: "all", text: "All" }, { key: "month", value: "month", text: "Month" }, { key: "year", value: "year", text: "Year" } ];

Estoy creando un nuevo objeto con este timeOptions siendo un valor de un campo en él. Cómo eliminar el objeto con la tecla "todos" in-place mientras se crea el objeto en sí

 const values = { timeVal: { field: "timestamp", label: "Timestamp", options: timeOptions } };

Código que probé

 const values = { timeVal: { field: "timestamp", label: "Timestamp", options: timeOptions.forEach((k) => delete k["key"] === "all") } };
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Usando Array#filter :

 options: timeOptions.filter(({ key }) => key !== 'all')
about 4 years ago · Juan Pablo Isaza Report

0

Si te entiendo bien, necesitas filtro .

 const values = { timeVal: { field: "timestamp", label: "Timestamp", options: timeOptions.filter((k) => k["key"] !== "all") }

};

Esto copiará todo excepto el que tiene la tecla "todos"

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!