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

196
Vistas
Assignment to property of function parameter 'item'

i have that lint error: Assignment to property of function parameter 'item'

What is the correct way to remove this error?

const resp = await getData(payload)
resp.forEach((item) => {
      item[0] = moment(item[0]).format('DD/MMM/YY');
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Here's an example with map.

const response = [ [ "07/10/2020", 0.04, 0.05, 0.04 ], [ "07/10/2020", 0.04, 0.06, 0.04 ] ];

// Iterate over the response
const data = response.map(item => {

  // For each item destrucuture the data from
  // the rest of the elements
  const [date, ...rest] = item;

  // Return a new array which has the updated
  // date, and the other elements then spread out
  return [
    moment(new Date(date)).format('DD/MMM/YY'),
    ...rest
  ];

});

console.log(data);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

Additional documentation

  • map

  • Destructuring assignment

  • Spread syntax

about 4 years ago · Juan Pablo Isaza 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