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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:10:54+00:00 2026-06-01T00:10:54+00:00

between saving a key name like this for(var key in this.data) { var key_name

  • 0

between saving a key name like this

    for(var key in this.data)
        {
            var key_name = key;
            for(key in this.data[key_name].content){
                alert(this.data[key_name].content[key].score);
            }
        }

or making checkpoint objects for every parent node

    for(var key in this.data)
        {
            var obj = this.data[key];
            for(key in obj.content){
                var  inner_obj = obj.content;
                alert(inner_obj[key].score);
            }
        }

which one has better performance? any other suggestion?

  • 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-01T00:10:55+00:00Added an answer on June 1, 2026 at 12:10 am

    Theoretically at least, the fastest would be to get the object reference outside the inner loop. In practice the difference might not be that big, if the browser is already doing this internally. Also, the performance might differ between browsers.

    for(var key in this.data) {
      var obj = this.data[key].content;
      for(var key2 in obj){
        alert(obj[key2].score);
      }
    }
    

    Note that you should use separate variables for the loops, otherwise it will be hard to follow which values is in the variable at which point when you put some actual code in the loops.

    Edit:

    When I measure the performance in IE and Firefox, I find that this method is slightly faster than the methods proposed in the question. However, the difference is so small that you should not be concerned with it. Either method works just fine, and any performance concerns would be what you actually do with the values inside the inner loop.

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

Sidebar

Related Questions

I would like to know the difference between saving data to an element using
In this question I was having problem with saving objects that had foreign keys
I've been investigating alternative methods for saving my game's data between turns, and wonder
Between Mysql and PostgreSQL,which is suite for very large scale of data..for example, millions
I am saving a managedObjectContext with certains objects, but not with all the relationships
I cannot decide between the following two patterns for eg. saving a dataObject (bean
I'm trying out the HTML5 localStorage method for saving data. As I understand it,
We are in the process of selecting the best method for saving state between
What is the difference between true and false in this code? public void onCheckedChanged(CompoundButton
I have one-to-many relationship between parent and child Java objects. The parent object uses

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.