Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:00:49+00:00 2026-06-07T13:00:49+00:00

Possible Duplicate: Javascript Variable Variables There’s a really handy thing in PHP (that I’m

  • 0

Possible Duplicate:
Javascript Variable Variables

There’s a really handy thing in PHP (that I’m sure is sinful), but I’m looking for the JavaScript alternative.

In PHP I can do this:

$bar = 'var';
$$bar= 'test';

echo $var;

I am looking for something similiar in JavaScript.
I want to pass a name to a function and initialize a new variable with that name.
So:

function(name) {
    var name = new Function();
}

Update:
Ok, here’s what I’m trying to do. I know there’s an easier way..

I want to use multiple instances of something (let’s say plupload for now).

var uploader = new plupload();

I am loading these dynamically and there will be multiples on a page.
The issue I’m having is that they all have to have a unique name, because I have to be able to call uploader.init(), uploader.refresh(), etc and have each one function independently.

As I said, I’m sure there’s a better way.. I’m just not privy to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:00:50+00:00Added an answer on June 7, 2026 at 1:00 pm

    It is sinful. In both PHP and JavaScript (and pretty much every other language) if you have a collection of related things, then you should represent them with an array (if they are ordered and not sparse) or an object/associative array (if they have names).

    var bar = 1;
    var foo = "test";
    var group = {};
    group[bar] = foo;
    console.log(group[1]);
    

    Variable variables are, essentially, fake arrays/objects. Use real ones instead — they give you much more power and are much easier to maintain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Get variable name. javascript “reflection” Is there a way to know the
Possible Duplicate: JavaScript Variable inside string without concatenation - like PHP In PHP, double
Possible Duplicate: How to get javascript variable value in php I am looking for
Possible Duplicate: Pass a PHP string to a Javascript variable (including escaping newlines) Hy,
Possible Duplicate: Pass a PHP string to a Javascript variable (including escaping newlines) So
Possible Duplicate: How to pass a variable / data from javascript to php and
Possible Duplicate: Using a javascript variable to set PHP variable I need to do
Possible Duplicate: How to access PHP variables in JavaScript or jQuery rather than <?php
Possible Duplicate: Passing javascript variable to PHP Hi I wonder if it's possible to
Possible Duplicate: What's the best way to pass a PHP variable to Javascript? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.