0

I have a variable: var a = "testing_here", and I want to create another variable, but I want its name to be the value of a. For example, in a perfect world, it would look something like this: var testing_here = _______

How can I get this desired result?

1 Answers1

-1

You can use bracket notation:

var a = "testing_here"
window[a] = "___";
console.log(testing_here);
Spectric
  • 30,714
  • 6
  • 20
  • 43
  • 2
    Man. Thank you so much for your quick AND accurate answer! I'll accept in 12 mins –  Aug 14 '21 at 18:38