Last active
August 29, 2015 14:21
-
-
Save iamso/964bed3b55cd5c4a0acb to your computer and use it in GitHub Desktop.
Console helper functions
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
window._debug = true; | |
// ... | |
var logTable = function(data, prefix){ | |
var table = [], | |
i, | |
value, | |
isArray; | |
!function toTable(data, prefix) { | |
for (i in data) { | |
value = data[i]; | |
isArray = Array.isArray(value); | |
(/^o/.test(typeof value) && !isArray) ? | |
toTable(data[i], prefix ? prefix + '.' + i : i) : | |
table.push({name: prefix ? prefix + '.' + i : i, value: isArray ? ''+value : value}); | |
} | |
}(data, prefix); | |
window._debug && console.table(table); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment