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

282
Views
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 answers
Answer question

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 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!