To make it easy to understand the methods that each JavaScript object contains, I write a function.
1 functiongetcollection (obj) {2 Try{3 if(obj) {4 varStype= "";5 varSmessage= "";6 for(varIinchobj) {7 if(Obj[i] = = =NULL|| Obj[i] = = =undefined) {8Stype= "I";9smessage + = "\ r \ n" +i;Ten } One Else{ A varc =Obj[i]; - if(C.name &&c.value) { -smessage + = "\ r \ n" + (C.name + ":" +c.value); theStype= "Name:value"; - } - Else{ -smessage + = "\ r \ n" + (i + "=" +obj[i]); +Stype= "Obj[i]"; - } + } A } atsmessage + = "\ r \ n" + ("Stype:" +stype); - alert (smessage); - } - } - Catch(err) { -Alert ("ERR:" +err.message); in } -}View Code
For example, look at the location of all methods and values, can be called by the following JS
GetCollection (location);
The Popup interface is as follows:
You can also view the contents of a JSON : Var json ={"name": "Zhang San", "Depart": "Sales department", "Skill": ["Java", "C + +", "PHP", "C #"]};
GetCollection (JSON);
To view the contents of an array :
var arry =["1", "5", "C"];
GetCollection (Arry);
Fast learning JavaScript objects-traversing objects