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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:28:39+00:00 2026-06-12T05:28:39+00:00

This question ( Element accessible with ID ) points out that if an element

  • 0

This question ( Element accessible with ID ) points out that if an element has an id then you can access it by variable name based on that id. It intrigued me, as I had seen this variable available when developing using Visual Studio 2010. I did some testing out of curiosity and it turns out that document.getElementById() was still faster than using the variable name. So, I began trying to look through the window, figuring it must be in window["idName"], in debug, and with console.log(window) and could not find where the variable was actually stored.

When an element is defined in html with <div id="foo"> it is available in javascript with the variable foo (I am not suggesting to use this, it is bad practice). Where is that variable stored?

  • 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-12T05:28:40+00:00Added an answer on June 12, 2026 at 5:28 am

    This is non-standard behavior. Where (and if) it is stored is up to the implementation.


    Using Firefox 15 on Linux, I had to go 2 prototype objects deep to find the actual object. I ran this code on this StackOverflow page, and got a true result.

    Object.getPrototypeOf(Object.getPrototypeOf(window)).hasOwnProperty("hlogo");
    

    In Chrome on Linux, it was one level deep.

    Object.getPrototypeOf(window).hasOwnProperty("hlogo");
    

    I was actually surprised to see it in Firefox, but since Chrome followed the Microsoft pattern, I guess Firefox must have felt the need to follow suit.


    If you don’t know how deep a prototype chain is, you can run a loop, and add the different objects to an Array, or just work with the objects in the loop.

    var protos = [],
        obj = window;
    
    while (Object.getPrototypeOf(obj) !== null) {
        obj = Object.getPrototypeOf(obj);
        protos.push(obj);
    }
    
    alert("The object had " + protos.length + " prototype objects");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read this question to figure out how to set float:none on an element
Related to this question here. Can I check if an element in the DOM
I'm looking for a way to clone a canvas element. Based on this question
I see this question . How can I get the last element in a
This question was inspired by this answer to another question, indicating that you can
Note: Before reading this question and its answer, please check your input element has
While looking for keyboard-accessible menus, I stumbled across this question , which has as
I everybody, I have qustioned this question already in that post: center flash element
This is probably a Microsoft interview question. Find the kth smallest element (ignoring duplicates)
Sorry if this question has already been answered, and sorry if it's too subjective

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.