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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:28:06+00:00 2026-05-31T10:28:06+00:00

I need to temporarily track the state of 5 objects in JavaScript. Each of

  • 0

I need to temporarily track the state of 5 objects in JavaScript. Each of these objects has a GUID as its id. Because of this, I was hoping to create an array of key/value pairs that I can work with. The key of each pair would be the id of each object. The value of each pair would be a boolean value. My problem is, I am really not sure how to do this in JavaScript. Currently, I have the following:

var myKeyValuePairs;

var myObjects = getMyObjects();
for (var i=0; i<myObjects.length; i++) {
  var id = myObjects[i].id;
  // What do I do now?
}

How do I build an array of key/value pairs in JavaScript?

  • 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-31T10:28:08+00:00Added an answer on May 31, 2026 at 10:28 am
    var myKeyValuePairs = {},
        myObjects = getMyObjects(),
        i, obj
    
    for (i=0, len = myObjects.length; i < len; i++) {
        obj = myObjects[i]
        myKeyValuePairs[obj.id] = obj
    }
    

    Or if you really want to use an array you could do something like

    var myKeyValuePairs = getMyObjects.map(function (obj) {
        return {
            key: obj.id,
            value: obj
        }
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to temporarily store my macro's settings for each worksheet. I thought about
I need to temporarily shut down a web sub-directory and all of its sub-directories
I need to setup temporary User models for each visitors, where the visitors are
I need a way to store a value somewhere for temporarily by say Process
I have a situation where I need to use some strings temporarily but I've
I need to store uploaded files temporarily while a user decides how they want
I need to store data temporarily at the client-side to allow users to add,
I wonder if someone here can help me figure out this problem. I need
I need to temporarily access the network to separate directories. When do it I
I have a situation where I temporarily need to save a bunch of settings

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.