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

111
Views
How to destructure an array/object

I want to destructure this but i can't get it (I need the vcardArray)

I can't get it with .vcardArray or with const { vcardArray } = *variablename

[
    { 
        objectClassName: 'entity', 
        handle: '292', 
        roles: ['registrar'], 
        publicIds: [[Object]], 
        vcardArray: ['vcard', [Array]], 
        entities: [[Object]]
    }
]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Destructuring syntax is exactly the same as object and array literal syntax,¹ it's just interpreted the other way around (and it's more common for us to use the shorthand {name} form than the full {name: name} form, though both are used).

So if you think about how you'd create an array with an object with a vcardArray property, that's how you destructure it.

const [ { vcardArray } ] = /*...your object...*/;

¹ With one caveat: The innermost tokens have to be assignable targets, so they can't be literals. {example: 42} is a valid object literal (creating an object with an example property and setting that property to 42), but you can't use it as a destructuring pattern because it would mean "get the example property and assign it to 42" you can't assign to the literal 42.

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!