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

162
Views
How to replace .Id with a variable string value

I currently have the following in my Javascript code where Id is a field of an object:

this.recId = event.detail.row.Id;

I want to make the Id part generic something like

String a = 'Id';
this.recId = event.detail.row.a;

How do I achieve this in Javascipt

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

0

Use [ ] instead.

const obj = {
  id: "myObject"
}

const a = "id"

console.log(obj[a]);

In your example, it would be

this.recId = event.detail.row[a];
about 4 years ago · Juan Pablo Isaza Report

0

You can use this.recId = event.detail.row[a] to get the desired result

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!