输出一个javascript对象的所有属性和方法,用于Debug

View Code
 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 } 
posted @ 2012-05-21 09:25  singleboss  阅读(228)  评论(0编辑  收藏  举报