Created
January 31, 2015 19:02
-
-
Save rpavlovic/30799a63cd9cac877538 to your computer and use it in GitHub Desktop.
Use JavaScript to list any/all properties of any JS object (native or custom)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Each browser/device has their set of JS properties (some more secret than others) | |
Use JavaScript to list any/all properties of any JS object (native or custom) | |
An old method of mine from the "browser wars" | |
*/ | |
var logger = logger || { | |
getProperties : function(obj) { | |
var props = []; | |
for(var n in obj) { | |
var prop = obj.toString() + "." + n; | |
props.push(prop); | |
} | |
if(console) { | |
console.log(props.join("\n")); | |
} | |
else { | |
var win = window.open('','','width=800,height=600'); | |
with(win.document) { | |
open(); | |
writeln(props.join("<br>")); | |
close(); | |
} | |
win.focus(); | |
} | |
} | |
}; | |
logger.getProperties(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment