Skip to content

Instantly share code, notes, and snippets.

@pseudosavant
Forked from jonathansampson/Proto-Crawler.js
Created March 7, 2014 21:28
Show Gist options
  • Save pseudosavant/9420508 to your computer and use it in GitHub Desktop.
Save pseudosavant/9420508 to your computer and use it in GitHub Desktop.
var output = (function ( object ) {
"use strict";
var names = [];
var props = Object.getOwnPropertyNames( object );
var proto = Object.getPrototypeOf( object );
while ( proto ) {
names = Object.getOwnPropertyNames( proto );
for ( var i = 0; i < names.length; i++ ) {
if ( props.indexOf( names[i] ) < 0 ) {
props.push( names[i] );
}
}
proto = Object.getPrototypeOf( proto );
}
props = props.sort(function ( a, b ) {
return a < b ? -1 : a > b ? 1 : 0;
});
return props;
}( this ));
/* Choose how you'd like it output */
document.body.style.whiteSpace = "pre";
document.body.textContent = JSON.stringify( output, null, "\t" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment