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

82
Views
How to access deeply nested array in Javascript

I have to access data from an API that is similar to:

{
 "name": "nameofevent",
 "speakers": [
   {
     "name": "speakerName"
   }
 ]
}

I am not sure how to access the speakerName inside speakers. Below is what I have, but I don't think I can do it that way because the speaker name has the same variable name as name. How would I access the speakerName?

{publicEvents.map((event) => {
    const { name, speakers: [{name}]} = event;
    return (
        <EventsCard
            eventName={name}
            speakerName={name}
        />
    ); 
})}

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

0

You can assign different variable names when destructuring.

{publicEvents.map((event) => {
    const { name: eventName, speakers: [{name: speakerName}]} = event;
    return (
           <EventsCard
                 eventName={eventName}
                 speakerName={speakerName}
           />
      ); 
    })}

about 4 years ago · Juan Pablo Isaza Report

0

As James said, it is an array so you need to specify that item in the array, since it is possible to have multiple speakers. Something like this could be used to select the first item:

speakers[0].name
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!