Created
September 15, 2014 04:45
-
-
Save kiidax/b41ed2ce0955f1ce4e3f to your computer and use it in GitHub Desktop.
Dump Object properties of JavaScript
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="author" content="Katsuya Iida"> | |
<title>JavaScript Object properties</title> | |
</head> | |
<body> | |
<h1>JavaScript Object properties</h1> | |
<table border="2" style="font: 12px monospace"> | |
<tr><th>Name<th>Class properties<th>Instance properties</tr> | |
<script> | |
function print(x) { document.write(x); } | |
[ Object, String, Math, RegExp, Function, Array, Boolean, Number, Date, Error ].forEach(function (x) { | |
var ok = Object.getOwnPropertyNames(x); | |
var pk = Object.getOwnPropertyNames(x.prototype || []); | |
print("<tr><td>" + x.name + ": " + ok.length + ", " + pk.length); | |
print("<td>" + ok.sort().join("<br>")); | |
print("<td>" + pk.sort().join("<br>") + "</tr>"); | |
}); | |
</script> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment