Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

655
Vistas
How to call a Object.keys as a variable not a text in array.push?

Help my problem is when the program runs, the values on Object.keys is on text, and i want it on variable form so it will call it on the EJS.

the output of the console.log(arr) will be (see code below):

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

The first arr.push (the one with Object.keys foreach loop) is the first three elements is called as text, and i want it on variable or look like the second arr.push.

The second arr.push(the one with dateString variable to the last push) is correct because it called from the 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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda