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

103
Views
¿Cómo accedo a la clave de un objeto pero quiero pasar la clave como una variable?

por ejemplo:

 object = { name: "Mike", age: 15 } object.age // returns 15 right?

Pero quiero pasar la clave 'edad' como nombre de variable:

 object = { name: "Mike", age: 15 } const age = 10.toString()

¿Cómo obtengo el resultado de algo como esto?

 object.`${age}`
about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Probar

 object["age"]

o

 var propName='age' object[propName]
about 4 years ago · Santiago Trujillo Report

0

Simplemente puede hacer esto por

 object[age]
about 4 years ago · Santiago Trujillo Report

0

Se puede acceder a las propiedades mediante . (notación de puntos) o mediante corchetes [] es decir:

 object[key_name] // where key_name is a variable object["some_key"] // {"some_key":"value"} or {some_value:"value"} object[19] // {19:"some_value"}
about 4 years ago · Santiago Trujillo 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!