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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:29:56+00:00 2026-06-01T16:29:56+00:00

I want to make a structure like this: var myThings = { thing1: {

  • 0

I want to make a structure like this:

var myThings = {
    thing1: {
        ['24-04-12', '90'],
        ['25-04-12', '90'],
        ['26-04-12', '90']
    },
    thing2: {
        ['24-04-12', '10'],
        ['25-04-12', '30'],
        ['26-04-12', '210']
    }
}

(There are 4 things, hardcoded).

The arrays in each object will be added in a loop, so my code looks like this:

var myThings = {"thing1":{}, "thing2":{}};

I then can’t work out how to push my arrays into the object.

Am I being dumb, or is this not the way to do this?

Thanks a lot!

  • 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-01T16:29:57+00:00Added an answer on June 1, 2026 at 4:29 pm

    You need to use an Array instead an Object there. Like

    var myThings = {
        thing1: [
            ['24-04-12', '90'],
            ['25-04-12', '90'],
            ['26-04-12', '90']
        ],
        thing2: [
            ['24-04-12', '10'],
            ['25-04-12', '30'],
            ['26-04-12', '210']
        ]
    }
    

    Now since thing1 and thing2 are Arrays you can just use Array.prototype.push to push new Arrays into that Array.

    Object.keys( myThings ).forEach(function( thing ) {
        myThings[ thing ].push( ['01-01-12', '42'] );
    });
    

    That code would add ['01-01-12', '42'] to all current things in that object.

    Disclaimer: The above code contains ES5. You need a browser which supports that or a Shim to emulate

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

Sidebar

Related Questions

I want make a simple referral system. Basically referral URL structure something like this.
I want to make array like this var ImageArray = [ {image:/image1.jpg}, {image:/image1.jpg}, {image:/image1.jpg}
I want to make a Jquery form, having form structure like this panel1{ Name
I want to make a table of orders, for each row there's an arrow
I have a html structure like this.. <div id=divid> <ul id=ulid> <li style=margin-left: 8px>
If I have a directory structure like this: package/ __init__.py functions.py #contains do() classes.py
Lets say I have a structure like this: Object A contains an instance of
I am building an ad analytics tool which assumes a data structure like this:
I want to make something similiar to this but with table rows I did
I'm trying to make an html table that looks like this: 1 2 3

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.