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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:00:35+00:00 2026-06-09T17:00:35+00:00

I have an object, which contains 2 name parameters – see the example below.

  • 0

I have an object, which contains 2 name parameters – see the example below. I understand that to reach the data I need to loop through the object, but I feel this is too annoying. Is there a better way to get the data in simple way?

var obj = {[[[{name:'one'},{name:'two'}]]]};

$.each(obj,function(i,val){
    var first = [] // i will get first time
    $.each(first, function(i, val){
        var second = [] //i will get second time and third later fourth  // like so?
    })
})

Does this mean that I should loop the each function four times to get the name values? If so which is the right way to get that? Is there any way to use the same function to get the data?

  • 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-09T17:00:36+00:00Added an answer on June 9, 2026 at 5:00 pm

    Your obj is invalid.

    So, try something this:

    var obj = [[[{
            name: 'one'},
        {
            name: 'two'}]]];
    
    $.each(obj[0][0], function() {
      alert( this.name );
    });
    

    DEMO


    Another one (for any level of array)

    var obj = [[[{
        name: 'one'},
    {
        name: 'two'}]]];
    
    function getObject(obj) {
        if (Object.prototype.toString.call(obj[0]) == '[object Array]') {
            getObject(obj[0]);
        } else {
            $.each(obj, function() {
                alert(this.name);
            });
        }
    }
    
    getObject(obj);​
    

    DEMO


    Note

    {} always contains data with key : value pair. So, in your case { [ .. ] } is invalid format of object. some correct formats of object may be:

    { key1: value1, key2: value2, .. }
    
    { data: [{key1: value1}, {key2: value2}] }
    

    Suggestion

    If you’ve option then change the format of your obj like below:

    var obj = [
       { name: 'one' },
       { name: 'two' }
    ];
    

    And try following code simply:

    $.each(obj, function() {
      alert( this.name );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object which contains 7 items. $obj.gettype().name Object[] $obj.length 7 I want
Suppose I have a class ObjectInfo which contains Object name & Object type as
I have a form which contains a whole heap of data entry fields that
Lets say I have an object which contains a persons name, and their city
I have object A which contains multiple instances of object B, which in turn
I have an object which contains models for my ASP.NET MVC web app. The
So I have an object which contains a set of objects in a private
If we consider a UML diagram where we have an object which contains a
I have a Car object which contains a latitude field and a longitude field.
I have an Object X which contains a list of Objects X. I do

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.