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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:07:08+00:00 2026-06-14T19:07:08+00:00

I an working in javascript and stuck in understanding the objects. Here is my

  • 0

I an working in javascript and stuck in understanding the objects.
Here is my scenario.

I have an object which in turn has multiple objects in it like.

data {
"aa" : object
"bb" : object
"cc" : object
}

//expanding aa bb and cc

aa {
name : "a"
type : "static"
value : "123"
}

bb {
name : "b"
type : "dyn"
value : "343"
}

cc {
name : "c"
type : "dyn"
value : "545"
}

Now what I want to achieve is that i have an object which should have those objects that have type = “dyn”
so i want to have a reqdata object like this

reqdata {
"bb" : object
"cc" : object
}

I have written a code to do this but it is not working as my reqdata has all the data.

   var reqData = $.each (data, function(key, d){
        if (type === "dyn")
            return d;                             
        });

Can any one guide me what the proper and efficient way of looping through the object.

Thanks any help and guidance will be appreciated

  • 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-14T19:07:09+00:00Added an answer on June 14, 2026 at 7:07 pm

    You need to create a new object, test the type property, and assign the current sub-object to the new one if the type is what you want.

              // v--- Holds the results
    var newObj = {};
                           //   v--- The current sub-object
    $.each(data, function(key, obj){
        if (obj.type === "dyn") // <-- Test its `type` property
            newObj[key] = obj;  // <--   and assign to `newObj` if it matches
    });
    

    You should note that you’re not making a copy of obj when you assign it to newObj. You’re making a copy of a reference to obj.

    This means that data and newObj share the same objects. Changes made via data are observable from newObj, and vice versa.

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

Sidebar

Related Questions

I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
I have this javascript which is working great - var employeename = $(#employeename); var
I am working with javascript and here is what I am trying to do:
So I have been working with javascript for a website I am designing, shocker
I'm working on a JavaScript and I got stuck with some verification : I'd
I'm currently stuck on a JavaScript / JSF issue. The project I'm working on
I'm working with Photoshop SDK with Javascript, and I'm completely stuck on the color
I have a working javascript file that adds and removes check boxes and drop
Hello all I am working in html5 and JavaScript and I am stuck in
I'm working on JavaScript and stuck in a small issue. I am receiving this

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.