JS对象格式化方法:pretty_format

/*
* 格式化
* */
var pretty_format = function (obj, indent) {
if (obj === null) return 'null';
if (obj === undefined) return 'undefined';
if (typeof obj === 'string') return '"' + obj + '"';
if (typeof obj !== 'object') return String(obj); if (indent == undefined) indent = ''; var result = '{\n';
for (var key in obj) {
result += indent + ' ' + key + ' = ';
result += format_pretty(obj[key], indent + ' ') + '\n';
}
return result + indent + '}';
}
上一篇:【loj3043】【zjoi2019】线段树


下一篇:iOS bug调试技巧学习----breakpoint&condition