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

205
Vistas
Change a variable's value through ES6 Interpolation

Consider this code

           switch (rackID) {
                case 1:
                    rack_data.rack1.temp = [temp1, temp2, temp3, temp4, temp5, temp6];
                    break;
                case 2:
                    rack_data.rack2.temp = [temp1, temp2, temp3, temp4, temp5, temp6];
                    break;
                case 3:
                    rack_data.rack3.temp = [temp1, temp2, temp3, temp4, temp5, temp6];
                    break;
                 

Notice how this code is repetitive whereas using this code would be useful rack_data.rack${rackID}.temp = [temp1, temp2, temp3, temp4, temp5, temp6] could be better, but this isn't allowed.

I know eval exists, but everyone says that it poses security issues so I'm trying to look for a alternative.

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