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

652
Views
¿Cómo llamar a Object.keys como una variable, no como un texto en array.push?

Ayuda, mi problema es cuando se ejecuta el programa, los valores en Object.keys están en texto, y lo quiero en forma variable para que lo llame en EJS.

la salida de console.log(arr) será (vea el código a continuación):

 [ 'req.body.name', 'req.body.age', 'req.body.sex', '2017-05-02 08:43:13', '031418003000', '1222', '1234', '01' ]

El primer arr.push (el que tiene Object.keys foreach loop) son los primeros tres elementos que se llaman texto, y lo quiero en variable o se parece al segundo arr.push.

El segundo arr.push (el que tiene la variable dateString hasta el último envío) es correcto porque llamó desde el EJS.

 var arr = []; var m = new Date(); var input = JSON.parse(JSON.stringify(req.body)); var dateString = m.getFullYear() + "-" + ("0" + (m.getMonth()+1)).slice(-2) + "-" + ("0" + m.getDate()).slice(-2) + " " + ("0" + m.getHours()).slice(-2) + ":" + ("0" + m.getMinutes()).slice(-2) + ":" + ("0" + m.getSeconds()).slice(-2); Object.keys(input).forEach(function(key) { arr.push('req.body.' + key); }); arr.push(dateString, req.body.eacode, req.body.hcn, req.body.shsn, req.body.MEMBER_CODE ); console.log(arr);
about 4 years ago · Santiago Trujillo
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!