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

  • Home
  • SEARCH
  • 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 6330369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:51:29+00:00 2026-05-24T17:51:29+00:00

I wonder if someone can point me into the right direction on this. When

  • 0

I wonder if someone can point me into the right direction on this. When I have an object, I usually read its properties via FOR IN LOOP. And since I know what the properties are because I created the very object, I know what keys and their values are. I would like to know if there are any other ways such as recursive approach to read through an object and its properties.

So here is the object for an example:

var mObj = {};
mObj.mArr = [];
mObj.mArr.push({id:['id1','id2','id3']});
mArr.push({days:['Monday','Tuesday','Wednesday','Thursday']});
mObj.mArr.push({colors:['orange','red','blue','green','yellow','white']});

As you can see, I have declared the mObj and within it, I have declared mArr as an Array. And then I am pushing three objects within mArr:

  1. id
  2. days
  3. colors

if I wanted to find out mArr length, I would write something like:

alert(mObj.mArr.length);

And if I wanted to loop through the object, I would have something like this:

for(var a in mObj.mArr[0])
{
   alert(mObj.mArr[0][a]);
}

I wonder if I can just right one function and pass the parent object which happens to be “mObj” here, and this recursive function would through the “mObj” and list all of its properties from head to toe.

I would appreciate any input on this, please.

Thanks a lot.

  • 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-05-24T17:51:30+00:00Added an answer on May 24, 2026 at 5:51 pm

    Here’s a basic example:

    var mObj = {};
    mObj.mArr = [];
    mObj.mArr.push({id:['id1','id2','id3']});
    mObj.mArr.push({days:['Monday','Tuesday','Wednesday','Thursday']});
    mObj.mArr.push({colors:['orange','red','blue','green','yellow','white']});
    
    function r(obj) {
        if (obj)
            for (var key in obj) {
                if (typeof obj[key] == "object")
                    r(obj[key]);
                else if (typeof obj[key] != "function")
                    console.log(obj[key])
            }
    
        return;
    } 
    
    r(mObj);
    

    if there is an object not a function call the function again, else console log the value if it is not a function.

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

Sidebar

Related Questions

I wonder if someone can answer this; I have a canvas app, which in
I wonder if someone could kindly point me in the right direction. I am
wonder whether someone can help me with the following one... I have a struct
I wonder if someone can help shed some light on this: I drop a
I wonder if someone can clarify what the f behind a floating point number
I wonder if someone give me a solution to this. How can I get
I wonder if someone can help a google analytics novice out? Basically I have
I wonder if someone here can help me figure out this problem. I need
I wonder whether someone can help me please. I've put together this page which
I wonder whether someone can help me please. I have the following three tables:

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.