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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:20:34+00:00 2026-06-10T06:20:34+00:00

This simple fiddle shows properties of Window object: var obj = this; // object

  • 0

This simple fiddle shows properties of Window object:

var obj = this; // object Window
var variables = "";
for (var name in obj) {
    if (obj.hasOwnProperty(name)) {
        variables += name + " : " + obj[name] + "<br/>";
    }
}
document.writeln(variables);

When this script is called directly with no wrap it shows this result:

window : [object Window]
document : [object HTMLDocument]
InstallTrigger : [object Object]
obj : [object Window]
variables : window : [object Window]  document : [object HTMLDocument]  InstallTrigger : [object Object] obj : [object Window]
name : name
getInterface : function getInterface() { [native code] }
location : http://fiddle.jshell.net/_display/
navigator : [object Navigator]

But when called onload it shows only:

window : [object Window]
document : [object HTMLDocument]
InstallTrigger : [object Object]
getInterface : function getInterface() { [native code] }
location : http://fiddle.jshell.net/4x3Tx/2/show/
navigator : [object Navigator]

And so the question is obvious: can somebody explain why are obj, variables and name variables missing from the second fiddle results? In both cases the obj refers to Window object.

  • 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-10T06:20:35+00:00Added an answer on June 10, 2026 at 6:20 am

    When you run the code “onLoad”, it is put inside a function and assigned to window.onload:

    window.onload=function(){
        var obj = this;
        var variables = "";
        for (var name in obj) {
            if (obj.hasOwnProperty(name)) {
                variables += name + " : " + obj[name] + "<br/>";
            }
        }
        document.writeln(variables);
        console.log(obj);
    }
    

    obj, variables and name are now local to that function, not global and hence are not properties of the window object.

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

Sidebar

Related Questions

This simple script should theoretically check the form for errors and then print any
This simple regex matching returns a string instead of an object on every browser
Consider this simple example - public class Person { private String name; private Date
I've written this fiddle to demo the problem. I have a simple form. When
Consider this jsfiddle: http://fiddle.jshell.net/maple/JbEJN/show/ (this is the result window, in order for replaceState to
I have this Fiddle : http://jsfiddle.net/2nAEZ/3/ the idea is very simple... when the page
Please see this simple fiddle http://jsfiddle.net/75qSD/ I want it to decorate the element as
This simple query session = com.jthink.songlayer.hibernate.HibernateUtil.getSession(); Query q = session.createQuery(recNo from SongChanges); giving this
This simple example fails to compile in VS2K8: io_service io2; shared_ptr<asio::deadline_timer> dt(make_shared<asio::deadline_timer>(io2, posix_time::seconds(20))); As
This simple Python method I put together just checks to see if Tomcat is

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.