var obj2 = {
name: "猪八戒",
age: 28,
gender: "男",
sayHello: function() {
console.log("obj2调用对象的名字: " + obj2.name);
}
}
for (var n in obj2) {
//列举所有的属性名
console.log("obj的属性:" + n);
//获取属性值
console.log("obj属性的值:" + obj2[n]);
}
var obj2 = {
name: "猪八戒",
age: 28,
gender: "男",
sayHello: function() {
console.log("obj2调用对象的名字: " + obj2.name);
}
}
for (var n in obj2) {
//列举所有的属性名
console.log("obj的属性:" + n);
//获取属性值
console.log("obj属性的值:" + obj2[n]);
}