Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda