for (var name in window) { if (window.hasOwnProperty(name)) { window.console.log ( name + " : " + window[name]); } else { //alert(name); // toString or something else }}javaScript 对象的hasOwnProperty方法打印window自定义属性