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

156
Views
¿Cómo agregar un objeto a una matriz de índice específica en javascript?

Tengo datos de ejemplo como este

 let datas = [ { no : '1', list: [ {val: '1'}, {val: '3'},{val: '4'}] }, { no : '2', list: [ {valNew: '11'}, {valNew: '13'},{valNew: '14'}] } ]

sus expectativas son asi

 let datas = [ { no : '1', list: [ {val: '1'}, { val: '2'}, { val: '3'},{val: '4'}] }, { no : '2', list: [ {valNew: '11'}, {valNew: '13'},{valNew: '14'}] } ]

he intentado así

 const handleDuplicate = (index, idx, item) => { let data = [...datas.listInvoice] data[index] = { ...data[index] = { ...data[index], invoices: [...data[index].invoices.slice(idx+1, 0, item)] } } setDatas(prevState => { return { ...prevState, listInvoice: data } }) }

Quiero agregar un objeto a una matriz con una determinada posición, pero siempre falla y la matriz dentro de las facturas se convierte en [], ¿cuál es la solución para este caso?

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!