Created
July 8, 2014 18:33
-
-
Save blackmjck/e5d51494349cda29b15f to your computer and use it in GitHub Desktop.
Utility for listing out all properties of an object.
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
/** | |
* 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