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

The Archive Base Latest Questions

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

Since now, I’m using this loop to iterate over the elements of an array,

  • 0

Since now, I’m using this loop to iterate over the elements of an array, which works fine even if I put objects with various properties inside of it.

var cubes[];

for (i in cubes){
     cubes[i].dimension
     cubes[i].position_x
     ecc..
}

Now, let’s suppose cubes[] is declared this way

var cubes[][];

Can I do this in JavaScript? How can I then automatically iterate in

cubes[0][0]
cubes[0][1]
cubes[0][2]
cubes[1][0]
cubes[1][1]
cubes[1][2]
cubes[2][0]
ecc...

As a workaround, I can just declare:

var cubes[];
var cubes1[];

and work separately with the two arrays. Is this a better solution?

  • 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-06-01T09:56:53+00:00Added an answer on June 1, 2026 at 9:56 am

    You can do something like this:

    var cubes = [
     [1, 2, 3],
     [4, 5, 6],    
     [7, 8, 9],
    ];
    
    for(var i = 0; i < cubes.length; i++) {
        var cube = cubes[i];
        for(var j = 0; j < cube.length; j++) {
            display("cube[" + i + "][" + j + "] = " + cube[j]);
        }
    }
    

    Working jsFiddle:

    • http://jsfiddle.net/TRR4n/

    The output of the above:

    cube[0][0] = 1
    cube[0][1] = 2
    cube[0][2] = 3
    cube[1][0] = 4
    cube[1][1] = 5
    cube[1][2] = 6
    cube[2][0] = 7
    cube[2][1] = 8
    cube[2][2] = 9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can select the first item in the div using $('.class:first') Now since I
I'm executing an external script, using a <script> inside <head> . Now since the
EDIT: This question is now redundant since Twitter no longer supports basic auth. I've
I been using VS2008 Pro for a long time now but since of licensing
Since now javascript gets compiled to machine code by browsers. I was wondering which
I've been working in ASP.NET for several years now (since the 1.0 days!), but
Since recent update Xcode 4.3 now seems to default to LLDB debugger. I just
It's been now a long time since I try to figure out how to
Since a few months I've been learning Erlang, and now it was time to
Its a long time since I've used C but now I'm trying to compile

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.