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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:11:47+00:00 2026-05-28T14:11:47+00:00

I have associated array: [ { attr_1:value 1_1, attr_2:value 2_1, attr_3:value 3_1 }, {

  • 0

I have associated array:

[
    {
        "attr_1":"value 1_1",
        "attr_2":"value 2_1",
        "attr_3":"value 3_1"
    },
    {
        "attr_1":"value 2_1",
        "attr_2":"value 2_2",
        "attr_3":"value 2_3"
    },
    {
        "attr_1":"value 1_1",
        "attr_2":"value 3_2",
        "attr_3":"value 3_3"
    }
]

And I need to get full object, by requesting ‘value 1_1’, for example. After request I want to see Object 1 and Object 3. I suppose that i need hash, but i don’t know how πŸ™

How can I do this correctly?

  • 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-28T14:11:48+00:00Added an answer on May 28, 2026 at 2:11 pm

    This is the perfect case for Array.filter!

    yourArray.filter( function(elem) {
      // Loop attr_1, attr_2, attr_3
      for ( var i in elem ) {
        if ( elem[i] == 'value 1_1' ) {
          return true;
        }
      }
    });
    

    Array.filter is native in all the browser but not on IE8 and below.
    In that case you have to include this polyfill

    /**
     * Copyright (c) Mozilla Foundation http://www.mozilla.org/
     * This code is available under the terms of the MIT License
     */
    if (!Array.prototype.filter) {
        Array.prototype.filter = function(fun /*, thisp*/) {
            var len = this.length >>> 0;
            if (typeof fun != "function") {
                throw new TypeError();
            }
    
            var res = [];
            var thisp = arguments[1];
            for (var i = 0; i < len; i++) {
                if (i in this) {
                    var val = this[i]; // in case fun mutates this
                    if (fun.call(thisp, val, i, this)) {
                        res.push(val);
                    }
                }
            }
    
            return res;
        };
    }
    

    More info:
    http://www.diveintojavascript.com/core-javascript-reference/the-array-object/array-filter

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

Sidebar

Related Questions

I have a JSON array(?) of pairs of every state and a value associated
I have a huge array of ints that I need to sort. The catch
I have a number of items in an array, each one associated to a
I have a string-array, that i need to display in a layout. The code
I have an array containing data (ID numbers and data associated with them). The
I have an array of pixels with an associated intensity (as a float between
What to look for when I have associated a CSS file with my Default.aspx
I have a table where I have datetimes associated with an ID: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
I have a User class which may or may not have an associated Department.
I have a Person class. A Person can have an associated control. Can I

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.