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

123
Views
¿Hay alguna manera de usar cadenas con la propiedad de algún objeto en javascript?

es difícil de explicar, pero sigamos con un ejemplo

 const exampleProperty = { log1: () => { console.log('log1') }, log2: () => { console.log('log2') }, log3: () => { console.log('log3') }, log4: () => { console.log('log4') } } for (let i = 0; i < 4; i++) { // now here I want to run all the functions in the example Property // I imagined it something like exampleProperty.log${i} // but this is invalid syntax }

Puede haber una respuesta muy fácil a esto, pero como soy nuevo, realmente no puedo imaginar qué hacer.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Si quisiera enumerar todos los métodos

 const exampleProperty = { log1: () => { console.log('log1') }, log2: () => { console.log('log2') }, log3: () => { console.log('log3') }, log4: () => { console.log('log4') } } Object.values(exampleProperty).forEach(p => p())

about 4 years ago · Juan Pablo Isaza Report

0

Ejemplo de trabajo, usando backticks

 const exampleProperty = { log1: () => { console.log('log1') }, log2: () => { console.log('log2') }, log3: () => { console.log('log3') }, log4: () => { console.log('log4') } } for (let i = 1; i <= 4; i++) { // now here I want to run all the functions in the example Property // I imagined it something like exampleProperty[`log${i}`](); // but this is invalid syntax }

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!