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

142
Views
How to create a new index array in javascript?

I have an array toolList

toolList = [{
      tbl_gaveta_NUMERO: '3',
      tbl_gaveta_DESCRIPCION: 'GAVETA CLORO',
      tbl_herramienta_FECHA: '2021-11-02',
      tbl_herramienta_NOMBRE: 'EXACTO',
      tbl_herramienta_CODIGO: '354']}

How to create another index to add a new variable called cantidad? As an example, the cantidad variable to be assigned to cantidad index.

toolList = [{
      tbl_gaveta_NUMERO: '3',
      tbl_gaveta_DESCRIPCION: 'GAVETA CLORO',
      tbl_herramienta_FECHA: '2021-11-02',
      tbl_herramienta_NOMBRE: 'EXACTO',
      tbl_herramienta_CODIGO: '354',
      cantidad: cantidad]}
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Adding a new item with the index 'cantidad' and value of the variable cantidad to your associative array using JavaScript method push():

let cantidad = 'test';

toolList.push({'cantidad': cantidad});
about 4 years ago · Juan Pablo Isaza Report

0

let cantidad
toolList[0]["cantidad"] = cantidad
about 4 years ago · Juan Pablo Isaza Report

0

When the variable name matches key name of the object, you can use ES6 syntax like that:

const cantidad = 'cantidad'
toolList.push({ cantidad })

MDN docs of the push method

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!