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

64
Views
Using const with curly brackets

I came across the following code:

const { userinfo } = userInfo;

I'm wondering, why do we use curly brackets with the const here?

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

0

In Javascript this syntax is called destructuring assignment and more specifically object destructing. Let's say you have an object:

const obj = { data: {...}, user: {...} }

For instance, when you write:

const { data, user } = obj
console.log(data)

Here you define new variables data and user and assign corresponding property values from the object obj to those variables.


It seems like in your case you have a local variable:

userInfo = {userInfo: {...} }
const { userinfo } = userInfo;

Deconstructing userInfo into { userInfo } would give you an error:

Uncaught SyntaxError: Identifier 'userInfo' has already been declared

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!