Skip to content

Instantly share code, notes, and snippets.

@blackmjck
Created July 8, 2014 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackmjck/e5d51494349cda29b15f to your computer and use it in GitHub Desktop.
Save blackmjck/e5d51494349cda29b15f to your computer and use it in GitHub Desktop.
Utility for listing out all properties of an object.
/**
* Introspect - Enumerates the closely-held properties of a given object in the browser console.
*
* Particularly useful for introspecting into DOM elements to see what the browser has tacked on.
*
* @author Steven Wiggins
* @date 7/8/2014
* @version 0.1
*/
; (function() {
"use strict";
function introspect ( obj ) {
var list = [], prop, i;
for( prop in obj ) {
if( obj.hasOwnProperty( prop ) ) {
list.push( prop );
}
}
console.log
i = list.length;
while( i-- ) {
console.info( '%c' + list[ i ] + ':', 'font-weight: bold;' );
console.log( obj[ list[ i ] ] );
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment