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

293
Views
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 answers
Answer question

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 Report

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 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!