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

292
Vistas
creating custom variables with names for another variable?

so i was trying to make custom variables generator but i couldn't figure out the way to create custom variavle with name from string it keeps sending error: Uncaught SyntaxError: Unexpected token '['

can someone help my code look like this:

var tempi = "csv"
var window[tempi]={0:"r"};

and i expect it to do

var csv ={0:"r"}

and create with this multiple variables with diffrent names

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The error is that you are using the var initializer word for window, but window is already defined when program loads, so just avoid it:

var tempi = "csv"

window[tempi] = {
    0: "r"
};

console.log(csv)

about 4 years ago · Juan Pablo Isaza Denunciar

0

Your code looking good. It seems that you dont define window['csv'] previously. Take a look on this example:

tempi = 'csv'
data = [];
data['csv'] = {0: 'hello'};

console.log(data[tempi])

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