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

269
Views
¿Cómo convertir un elemento específico en una matriz a número?

Quiero convertir el ID de archivo que está en la matriz actual de string a number , por ejemplo: fileID: "1" a fileID: 1 .

¿Cómo apuntar al elemento específico (fileID) para que pueda convertirlo en un number y asignar la matriz actual a una nueva matriz?

Matriz actual:

 [ { fileID: "1", fileName: "Cardio Care Awareness Month", createdByID: "100101" }, { fileID: "2", fileName: "MEMO COMPULSORY TO", createdByID: "100101" }, { fileID: "3", fileName: "MEMO 2021 Covid19 Vaccination Leave", createdByID: "200201" }, { fileID: "4", fileName: "Human Cell", createdByID: "200201" } ]

Nueva matriz convertida:

 [ { fileID: 1, fileName: "Cardio Care Awareness Month", createdByID: "100101" }, { fileID: 2, fileName: "MEMO COMPULSORY TO", createdByID: "100101" }, { fileID: 3, fileName: "MEMO 2021 Covid19 Vaccination Leave", createdByID: "200201" }, { fileID: 4, fileName: "Human Cell", createdByID: "200201" } ]

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Aquí hay una función que debería convertir la matriz al formato que desee.

 const convertArray = array => array.map(({fileID, ...item}) => ({fileID: Number(fileID), ...item}))
about 4 years ago · Juan Pablo Isaza Report

0

Puede crear una función personalizada y reutilizarla en su aplicación.

Ejemplo :

 const parseData = (data, key) => { return data.map(item => { return { ...item, [key] : Number(item[key]) } }) } parseData(data, 'fileID') 0: {fileID: 1, fileName: 'Cardio Care Awareness Month', createdByID: '100101'} 1: {fileID: 2, fileName: 'MEMO COMPULSORY TO', createdByID: '100101'} 2: {fileID: 3, fileName: 'MEMO 2021 Covid19 Vaccination Leave', createdByID: '200201'} 3: {fileID: 4, fileName: 'Human Cell', createdByID: '200201'}
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!