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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:08:41+00:00 2026-06-08T12:08:41+00:00

I am trying to break a javascript object in to small array so that

  • 0

I am trying to break a javascript object in to small array so that I can easily access the innerlevel data whenever I needed.

I have used recursive function to access all nodes inside json, using the program

http://jsfiddle.net/SvMUN/1/

What I am trying to do here is that I want to store these in to a separate array so that I cn access it like

newArray.Microsoft= MSFT, Microsoft;
newArray.Intel Corp=(INTC, Fortune 500);
newArray.Japan=Japan
newArray.Bernanke=Bernanke;

Depth of each array are different, so the ones with single level can use the same name like I ve shown in the example Bernanke. Is it possible to do it this way?

  • 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-08T12:08:42+00:00Added an answer on June 8, 2026 at 12:08 pm

    No, you reduce the Facets to a string named html – but you want an object.

    function generateList(facets) {
        var map = {};
        (function recurse(arr) {
            var join = [];
            for (var i=0; i<arr.length; i++) {
                var current = arr[i].term; // every object must have one!
                current = current.replace(/ /g, "_");
                join.push(current);  // only on lowest level?
                if (current in arr[i]) 
                    map[current] = recurse(arr[i][current]);
            }
            return join;
        })(facets)
        return map;
    }
    

    Demo on jsfiddle.net

    To get the one-level-data, you could just add this else-statement after the if:

                else
                    map[current] = [ current ]; // create Array manually
    

    Altough I don’t think the result (demo) makes much sense then.

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

Sidebar

Related Questions

I have the vector output = PV_out(:); I am trying to break this down
below is something I am trying to do with JavaScript. If I have string
I'm trying to include script and style references that will not break on deployment,
In a JavaScript code, I am trying to re-name an object by its stored
I have a javascript function that, in most cases, needs to do something with
I've been trying to troubleshoot this, but can't find a good function that will
I am trying to write a star rating system in javascript that allows the
I am trying to use javascript, without framework(prototype, jQuery,etc), to insert data passed from
I am trying to get a PHP array variable into a JavaScript variable. This
I have one complicated situation with JavaScript. I have created object. This object loads

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.