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

The Archive Base Latest Questions

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

I just want the data in this way: var _2dimen = {}; _2dimen[‘window1’][‘panel1’] =

  • 0

I just want the data in this way:

var _2dimen = {};

_2dimen['window1']['panel1'] = '2010-10-01'
_2dimen['window1']['panel2'] = '2010-10-01'
...
_2dimen['window3']['panel1'] = '2010-10-01'

which window and panel number are dynamic.It means I could using the pattern of :
I mean: the variable of window and panel is dynamic create in my situation,the window may be window1 or window2… and panel may be panel2,panel4.

var window = windowNumber, panel= panelNumber;

_2dimen[window][panel] = 'some date here';

How can I struct the code to assign and edit the value?

the code I wrote just what I was thought it maybe,it didn’t work!!
_2dimen[window] = ‘data’ work fine and I adding the [panel]

 _2dimen[window][panel] = 'data' the firebug prompts me that :

_2dimen[window] is undefined
     _2dimen[window][panel] = date; 

Thank you very much!

  • 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-18T21:11:14+00:00Added an answer on May 18, 2026 at 9:11 pm

    What some call “associative arrays” in JS are just objects:

    var twoD = { window1: {
        panel1: '2010-10-01',
        panel2: '2010-10-02',
        ...
      }, 
      window3: {
        panel1: '2010-12-01',
        ...
      }
    };
    

    If you’re actually naming the indices things like ‘window1’ and ‘panel2’, a better approach would be to use arrays. This way, you can loop over panels and windows, yet still set other properties on the top level object and windows.

    var twoD = { windows: [
        { panels: ['2010-10-01', '2010-10-02', ...
        ...
        // window3
        { panels: ['2010-12-01']}
      ],
      foo: 'bar'
    };
    ...
    twoD.windows[0].panels[1] // '2010-10-02'
    

    And remember, identifiers can’t start with a digit.

    If the panels set on windows skip some indices, you can do that, too. Note that you can’t set properties of an undefined value. _2dimen[window][panel]={} fails when _2dimen[window] is undefined. You need to test & set the element at the major index before accessing an element at a minor index.

    function TwoD() {
        this.windows = [];
    }
    TwoD.prototype.window = function(i) {
        if (! this.windows[i]) {
            this.windows[i] = {panels: []};
        }
        return this.windows[i];
    };
    ...
    var wall = new TwoD();
    wall.window(2).panels[1] = '2010-12-02';
    

    This is very close to your current implementation, but has the advantage of allowing iteration over windows & panels when other properties are set.

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

Sidebar

Related Questions

I just want to know a easy way to extract all data with same
I just want to validate some data with nodejs & socket.io server-side. So I
I just want to intercept raw data (hex)--headers and all--sent to a port, and
Before Entering data into a database, I just want to check that the database
Seeing lots of SOAP/RDS stuff, but just want to dump some MySQL data and/or
My data is just number, I want pass it from VC1 to VC2 for
I have just scraped a bunch of Google Buzz data, and I want to
Just want to know if there is a way to detect how many times
this way i am sending my json data this way i construct my json
Why isn't this script working? $(function() { var isbn = $('input').val(); $('button').click(function() { $(#data).html('<iframe

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.