Skip to content

Instantly share code, notes, and snippets.

@kiidax
Created September 15, 2014 04:45
Show Gist options
  • Save kiidax/b41ed2ce0955f1ce4e3f to your computer and use it in GitHub Desktop.
Save kiidax/b41ed2ce0955f1ce4e3f to your computer and use it in GitHub Desktop.
Dump Object properties of JavaScript
<!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