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

285
Views
How to destructure a nested object with special character and using object alias

I have been wondering if there is a way I can destructure this object in the snippet.

enter image description here

Here is what I have tried but it seems not working...

const {
    _links: {
      self: [{ href: mainMedia }],
    },
    _links: { "wp:attachment": attachmentMedia:{[{href:attachment}]} },
    _links: { "wp:featuredmedia": featuredMedia:{[{href:attachment}] } }
  } = data;

The attachmentMedia and featuredMedia are my alias and I am interested in the link each array.

MDN docs seems not to have this

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

0

const [{ href: mainMedia }] = data._links["self"];

const attachmentMedia = data._links["wp:attachment"]
  .map(({ href: attachment }) => ({ attachment }));

const featuredMedia = data._links["wp:featuredmedia"]
  .map(({ href: attachment }) => ({ attachment }));

Is this your expectation?

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!