输出一个javascript对象的所有属性和方法,用于Debug
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 //返回一个对象的属性和方法,用于Debug 2 function getMethodAndPropertys(obj) { 3 var result = []; 4 for (var id in obj) { 5 try { 6 if (typeof(obj[id]) == "function") { 7 result.push("function " + id + ": " + obj[id].toString() + "<br /><br />"); 8 } 9 else { 10 result.push("property " + id + ": " + obj[id].toString() + "<br /><br />"); 11 } 12 } catch (err) { 13 result.push(id + ": inaccessible"); 14 } 15 } 16 return result; 17 }