Last active
April 4, 2017 20:25
-
-
Save juliozuppa/90e0bc3988e4dfe1338f4ddc15e9f252 to your computer and use it in GitHub Desktop.
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
function writeLn(str) { | |
document.write(str + '<br>'); | |
} | |
function printProperties(strPropertieName, maxLeval) { | |
var countLevel = 1; | |
var arr = typeof strPropertieName === 'string' ? eval(strPropertieName) : strPropertieName; | |
for(var a in arr) { | |
if(typeof arr[a] === 'object' && arr[a] !== null) { | |
if(countLevel < maxLeval) { | |
printProperties(strPropertieName + '[\'' + a + '\']', maxLeval - countLevel); | |
countLevel++; | |
} | |
} else if(typeof arr[a] != 'function') { | |
writeLn(strPropertieName + '[\'' + a + '\']: ' + arr[a]); | |
countLevel = 1; | |
} else { | |
countLevel = 1; | |
} | |
} | |
} | |
document.write('<pre>'); | |
printProperties('location', 3); | |
writeLn(''); | |
printProperties('screen', 3); | |
writeLn(''); | |
printProperties('navigator', 3); | |
writeLn(''); | |
printProperties('location', 3); | |
writeLn(''); | |
printProperties('window', 2); | |
writeLn(''); | |
/*printProperties('document', 1); // mais que 1 não rola (vai travar) | |
writeLn('');*/ | |
document.write('</pre>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment