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 5962163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:04:01+00:00 2026-05-22T19:04:01+00:00

Possible Duplicates: Is there a way to access a javascript variable using a string

  • 0

Possible Duplicates:
Is there a way to access a javascript variable using a string that contains the name of the variable?
JavaScript: Get local variable dynamicly by name string

A simple code to illustrate my problem –

var chat_1 = "one";

var chat_2 = "two";

var id = "1";

var new = ?? variabalize( 'chat_' + id ) 

I want the variable new to be assigned the value of variable – chat_1 which is “one”

  • 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-05-22T19:04:02+00:00Added an answer on May 22, 2026 at 7:04 pm

    Stop. Reorganise your code. If you want to select variables with a variable, then there has to be a logical grouping for them. Make it explicit.

    var chat = {
        "1": "one",
        "2": "two"
    };
    var id = 1;
    var new_is_a_keyword_and_cant_be_an_identifier = chat[id];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicates: ‘Friends’ equivalent for Java? Is there a way to simulate the C++
Possible Duplicate: Is there a way for MS Access to grab the current Active
Possible Duplicates: Is there any difference between “string” and 'string' in Python? Single quotes
Possible Duplicates: C - determine if a number is prime Is there any way
Possible Duplicates: Get image data in Javascript? How to encode image data within an
Possible Duplicates: How do I prevent CSS inheritance? is there a way to exclude
Is there a way to collect (e.g. in a List) multiple 'generic' objects that
Possible Duplicate: Is there a better way than parsing /proc/self/maps to figure out memory
Possible Duplicate: How to access PHP variables in JavaScript or jQuery rather than <?php
In Delphi 2009 and Windows API, is there a way to detect that a

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.