使用js遍历对象(递归)
<html>
<title>js遍历对象</title>
<body>
<script>
var cla = {
list: {
person: {
name: "shishuo",
number: 5
},
age: 20,
sex: "man"
},
dog: {
name: "apple",
age: 5,
sex: "woman"
}
}
Object.prototype.any = function (obj) {
Object.keys(obj).forEach(function (key){
if(typeof(obj[key])!=='object'){
console.log(obj[key]);
return;
}else{
any(obj[key]);
}
})
}
</script>
</body>
</html>