JavaScript traversal DOM structure and object structure

Source: Internet
Author: User

In practice, it is a good idea to keep an information or Web site by remembering that the object's properties and methods are almost impossible tasks in the browser. But it also takes a lot of time to access the data, and if a script can print out the structure of the object, it will speed up the development process.

Here is an example of the View object structure I wrote, please download the attachment to get the executable code:

//animal is an object Animal = {Createnew:function (bundle) {var Animal = {}; var protect = Bundle | |     
        {};//bundle Pass is the pointer, modify protect when the outside object will be changed (unless not transmitted) Protect.sound = ' growl ';      
        Protect.makesound = function () {return protect.sound;     
    return animal;     
        }//cat is also an object cat = {pubvar: "Cat", Createnew:function (mysound) {     
        var protect = {};     
        var cat = animal.createnew (protect);//protect will be modified, then return blank object {} to Cat protect.sound = Mysound;     
    Cat.meow = function () {return protect.makesound ();};//cat to call method return Cat in protect;     
//javascript is case-sensitive and constructs a new object assignment to cat var cat = cat.createnew ("meow!") by a Cat object;     
        
var bigcat = cat.createnew ("meow!meow!meow!");     
Showobject ("Cat");     
Showobject ("Cat"); Showobject ("Bigcat"); 
Debugging information:

[Object] Cat
|--[function] CreateNew = function (mysound) {var protect = {}; var cat = animal.createnew (protect);//protect will be modified, then return blank Object {} to Cat protect.sound = Mysound; Cat.meow = function () {return protect.makesound ();};//cat to invoke method return cat in Protect;}
|--[string] Pubvar = Cat

[Object] Cat
|--[function] Meow = function () {return protect.makesound ();}

[Object] Bigcat
|--[function] Meow = function () {return protect.makesound ();}

[Note 1] is similar to traversing the DOM structure, for example, a blog post will be written to show the IE10 window object. Specifically, the implementation of Showobject ("window") in IE10;

[Note 2]object type has a drill-down link, but there is a small problem: it is not possible to rollback, it is recommended to press the F5 key.)

This article is from the "idata" blog, please be sure to keep this source http://idata.blog.51cto.com/4581576/1103408

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.