好像是在<<王者归来>>上面看到的,如下: //调试级别 var DebugLevel = {Info:1,Warning:2,Error:3,Off:4}; var Debug = { level:DebugLevel.Info, //调试等级 //_output:alert, //输入方法,可改为document.write(IE only) _output:function(x){alert(x);}, //输入方法,可为document.write //watch method,监视对象属性值 _watch:function(obj,property){ var ret = []; if(!(obj instanceof Object)){ ret.push(obj); } else if(property) ret.push(property + ":" + obj[property]); else for(var each in obj){ ret.push(each+":"+obj[each]); } return ret; }, Output:function(level,args){ for(var i=0;i<args.length;i++){ if(Debug.level<=level){ Debug._output("level " +level + " : " +Debug._watch(args[i])); } } }, Info:function(){ Debug.Output(DebugLevel.Info,arguments); }, Warning:function(){ Debug.Output(DebugLevel.Warning,arguments); }, Error:function(){ Debug.Output(DebugLevel.Error,arguments); } } // Debug.level = DebugLevel.Info; Debug.Info("test"); var o1 = { "a":1, "b":2, "c":3 }; Debug.Warning(o1);