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

278
Vistas
how to automaticaly get values to set in params

i'm trying to execute external inputs with functions and params, get params values in database and changes this values before execute the functions, i create a exemple below to show my problem

// Values in DB
const InternalValues = {
  phone: '123456789',
  old: '25'
}

//Values from external inputs, when params old=param1 and phone=param2
const externalValues = {
  data: `return function exec(param1,param2){
            console.log("values",param1,param2)
        };`,
  params: ['old', 'phone'],
}

// Create a function
const Func = new Function(externalValues.data)();

//Finding ExternalParams in Internal Values manualy
const param1 = InternalValues[externalValues.params[0]]
const param2 = InternalValues[externalValues.params[1]]

// Execute Function
const ii = Func(param1, param2)
console.log(ii);

if i put more values in externalValues.params and externalValues.data, i will need to create param3, param4 ... to get values from InternalValues, how i automaticaly get all values from externalValues.params and put them to execute the function? is it possible without send in array with one param ?

Thanks, i hope than u understand that exemple.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Spread arguments will do it here:

// Values in DB
const InternalValues = {
  phone: '123456789',
  old: '25'
}

//Values from external inputs, when params old=param1 and phone=param2
const externalValues = {
  data: `return function exec(...params){
            console.log("values", ...params)
        };`,
  params: ['old', 'phone'],
}

// Create a function
const Func = new Function(externalValues.data)();

//Finding ExternalParams in Internal Values
const params = externalValues.params.map(p => InternalValues[p]);

// Execute Function
const ii = Func(...params);
about 4 years ago · Juan Pablo Isaza Denunciar
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