Skip to content

Instantly share code, notes, and snippets.

@iamso
Last active August 29, 2015 14:21
Show Gist options
  • Save iamso/964bed3b55cd5c4a0acb to your computer and use it in GitHub Desktop.
Save iamso/964bed3b55cd5c4a0acb to your computer and use it in GitHub Desktop.
Console helper functions
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