遍历对象

转载请注明来源:https://www.cnblogs.com/hookjc/

var str = '';
function ScanObj(obj){
var ct = '';
for (var o in obj){
if (typeof(obj[o]) == ''){
ct = ScanObj(obj[o]);
}else{
str += o + '=' + obj[o] + '\n';
}
}
return ct;
}

var tobj = {
a : 100,
b : 101,
c : 102,
d : 103
};
alert(ScanObj(tobj));

来源:python脚本自动迁移

posted @ 2020-06-24 11:02  jiangcheng_15  阅读(120)  评论(0编辑  收藏  举报