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

  • SEARCH
  • Home
  • 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 643451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:17:02+00:00 2026-05-13T21:17:02+00:00

I basically have the following string in the format: A,B,C:D,E,F What I am trying

  • 0

I basically have the following string in the format:

A,B,C:D,E,F

What I am trying to achieve is a means of pairing up left hand side JavaScript variable, to the left of the “:” with the right hand side values to the right of the “:”

I would like to have the following variables set in, so that I can use in my coding, i.e:

var A = D;
var B = E;
var C = F;

I can then use the values of A,B and C as parameters into other JavaScript functions.

I have looked at the split and slice methods for this string manipulation but unsure how to pair up left hand side with right hand side values.

  • 1 1 Answer
  • 1 View
  • 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-13T21:17:03+00:00Added an answer on May 13, 2026 at 9:17 pm

    With this method (attaching variables to an object), you can reference variables in code without an eval statement.

    a = "A,B,C:D,E,F";
    array = a.split(":"); //split on the colon, get two strings
    lefts = array[0];
    rights = array[1];
    
    obj = {} //object to attach variables to.
    for( var i = 0; i < lefts.length; i++ )
    {
      obj[lefts[i]] = rights[i]; //set the member variables of obj
    }
    
    obj.A // D
    obj.B // E
    obj.C // F
    

    If you care about the wasted comma property, check if lefts[i] is equal to a comma before you set on the object.

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

Sidebar

Related Questions

I'm having an issue with rails involving javascript. Basically, I have the following code:
I have string in following format some other string @[Foo Foo](contact:2) some other string
I basically have the following class: .sf-sub-indicator { background: url(/abcprod/images/arrows-ffffff.png) no-repeat -10px -100px; }
I am wondering if the following is possible in MVC 3 I basically have
Basically I have a new client that is after the following functionality from her
I have the following views in my application. Basically I want to call show_house()
I have created following thing in android using android compatibility support package Basically i
Basically, I have the following so far: class Foo { public override bool Equals(object
Is there any name for the following DB table design: Basically we have generic
Hey all, basically i have an empty AS3 fla file with just the following

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.