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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:19:48+00:00 2026-05-16T17:19:48+00:00

I’m wondering about access times on object members. More precisely, I’m benchmarking access times

  • 0

I’m wondering about access times on object members. More precisely, I’m benchmarking access times on the window object. I believe I can explain most behavior here on my own, but I’d feel better to hear some comments.

Usecase: Different access times on different propertys ?

I’m benchmarking on Firefox 3.6.8 (windows), the simple measuring code looks like:

var loop = 100000;

console.time('bench');
while(loop--){
   if(window.JSON)
      var foo = 0;
}
console.timeEnd('bench');

The first strange thing is, it makes a different which property I’m looking up. For instance, window.JSON seems to be faster to access, than window.localStorage. There are other propertys/methods which can get accessed even faster.
Since there is no specification or defination within in the the ECMA-262 Language Specification, which order keys must have in an object, I guess each browser vendor implements it’s own logic in which order keys are stored in memory.
Could this be an explanation for this behavior? Like, JSON is one of the very first keys and location is more at the end? (In my test environment at least)

—

Another thing I noticed is, that calling if(JSON) is slightly faster than if(window.JSON). If we forget about that you always should do the second call because of possible reference errors, those calls should have the same access time. I’m aware of ECMAscripts behavior on nested member lookups (A nested member will cause the Javascript engine to go through the object member resolution, each time a dot is encountered), so window.location.href must be slower than location.href, but in this case.. is there a difference between JSON and window.JSON ?

To end this, the fastest way to know whether or not the window object owns a specific property/method is to use the IN operator. That is about 10 times faster for the above examples.

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

    The first strange thing you notice might have to do about how host objects are implemented by the browser.

    localStorage is a host object, provided by the environment, JSON on the other hand, is a built-in object provided by ECMAScript.

    Try to resolve another built-in’s and you will get more or less the same results than with JSON.

    Now, the difference about JSON vs window.JSON:

    window is just a property on the global object that points to itself, when you access the window identifier the name resolution process takes place to find it.

    Basically referencing:

    JSON;
    

    Involves only one identifier lookup (in the scope chain), and:

    window.JSON;
    

    Involves an identifier lookup (window) and a property lookup (window.JSON).

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

Sidebar

Related Questions

No related questions found

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.