JavaScript gets the properties and property values in the object's direct volume:
The so-called direct amount of the object is simply a list of key-value pairs wrapped by braces, for example:
var antzone={ webName:"Ant Tribe", Address:"Shinan District, Qingdao", age :2}
Here's how to get the properties and property values in the object's direct amount, the code is as follows:
var antzone={ webName:"Ant Tribe", Address:"Shinan District, Qingdao", age :2 }for (var in antzone) { Console.log (prop+ ":" + Antzone[prop]);}
The above code implements our requirements and uses a for in loop to iterate through its properties, and more to read about it.
Related reading:
The 1.for in statement can be found in the section on the use of JavaScript for the in statement .
2.javascript objects can be found in several ways of creating objects in JavaScript section.
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=12199
For more information, refer to: http://www.softwhy.com/javascript/
JavaScript gets the attributes and property values in the direct amount of the object