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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:48:59+00:00 2026-05-22T02:48:59+00:00

I have an associative array: var array1 = { a1: { id: box1, title:

  • 0

I have an associative array:

var array1 = {
    a1: {
        id: "box1",
        title: "box 1"
    },
    a2: {
        id: "box2",
        title: "box 2"
    },
    a3: {
        id: "box3",
        title: "box 3"
    }
};

I then have another array which has references to the first array:

var array_order = ["a3:positionA", "a2:postitionB", "a1:positionC"];

I want to loop through the first list and then use the second list to find the position text

I am using jQuery so I have

$.each(array1, function(i,o) {
  something in here where I can use i to find out what position. e.g. if a1 I would get positionC
}
  • 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-22T02:48:59+00:00Added an answer on May 22, 2026 at 2:48 am

    Easier and faster iterate over array_order instead of array1:

    for( var i = 0, len = array_order.length; i < len; i++ ) {
        var ref = array_order[i].split(':');
    
        if( ref.length === 2 && ({}).hasOwnProperty.call( array1, ref[0] ) ) {
            var array1Property = array1[ ref[0] ];
            var array1PropertyPosition = ref[1];
        }
    } 
    

    Iteration over array1 properties can be realized also, but it’s significantly slower:

    for( var prop in array1 )
        if( ({}).hasOwnProperty.call( array1, prop ) )
            for( var i = 0, len = array_order.length; i < len; i++ ) {
                var ref = array_order[i].split(':');
                if( ref.length === 2 && prop === ref[1] ) {
                    var array1Property = array1[ prop ];
                    var array1PropertyPosition = ref[1];
                }
            }
    

    And there is no need in jQuery.

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

Sidebar

Related Questions

I have an associative array (object) of the following construction var menu = new
I got a phptal template question, I have an associative array which contains HTML
I have an associative array in the form key => value where key is
What is the best way to have an associative array with arbitrary value types
I want to create an associative array: var aa = {} // Equivalent to
I have an associative array that I want to display using TileList. However, it
I have an associative array of objects that I want to extend with a
I have an array of items as follows in Javascript: var users = Array();
Let's say I have an associative array like so: {'key1': 22, 'key2': 42} .
Lets say i have this array of movie directors: var directors = ['Woody Allen',

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.