Skip to content

Instantly share code, notes, and snippets.

@rpavlovic
Created January 31, 2015 19:02
Show Gist options
  • Save rpavlovic/30799a63cd9cac877538 to your computer and use it in GitHub Desktop.
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)
/*
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