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

124
Views
Default parentheses upon object destructuring

I've recently run into a problem that I can't fix.

I'm writing some code where I have to access data with the help of an input range field. I want to write a getData function which looks like this:

function getData() {
  let currentValue = slider.value;
  let index = currentValue - 1;
  return { pageViews, monthlyCost, leftPercentage } = viewsData[index];
}

this works BUT everytime I save my file visual studio code adds a parenthesis around the destructuring assigment like this:

return ({ pageViews, monthlyCost, leftPercentage } = viewsData[index]);

and after that the code doesn't work

can somebody help me with fixing this behavior in my code editor? thanks (:

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

I believe you have the prettier extension install in your IDE. To prevent this automatic behaviour for that specific line of code, you can use prettier-ignore and exclude the next line from formatting.

function getData() {
  let currentValue = slider.value;
  let index = currentValue - 1;

  // prettier-ignore
  return { pageViews, monthlyCost, leftPercentage } = viewsData[index];
}
about 4 years ago · Santiago Gelvez 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!