Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Closed as "Duplicate" by VLAZ javascript Users with the javascript badge or a synonym can single-handedly close questions as duplicates and reopen them as needed.
edited tags
Link
VLAZ
  • 29.6k
  • 9
  • 65
  • 88
Question Protected by Community Bot
edited title
Link
user2864740
  • 62.5k
  • 15
  • 159
  • 234

Javascript Use dynamic variable namenames in JavaScript

Source Link
Finbarr
  • 32.3k
  • 13
  • 67
  • 94

Javascript dynamic variable name

In PHP you can do amazing/horrendous things like this:

$a = 1;
$b = 2;
$c = 3;
$name = 'a';
echo $$name;
// prints 1

Is there any way of doing something like this with Javascript?

E.g. if I have a var name = 'the name of the variable'; can I get a reference to the variable with name name?

lang-js

AltStyle によって変換されたページ (->オリジナル) /