Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cpagravel/5b30c8dcbe96dac01116 to your computer and use it in GitHub Desktop.
Save cpagravel/5b30c8dcbe96dac01116 to your computer and use it in GitHub Desktop.
function printArray (arr, depth) {
depth++;
indentLog("[", depth);
for (var index in arr) {
if (typeof(arr[index]) == "object") {
if (typeof(arr) == "object")
indentLog(index + "=> Array", depth);
else {
indentLog(arr, depth);
indentLog(index, depth);
}
printArray(arr[index], depth);
} else {
indentLog(index + "=> " + arr[index], depth);
}
}
indentLog("]", depth);
}
function indentLog(msg,space) {
str = "";
for (var i = 0; i < (space*2); i++) {
str += ".";
}
str += msg;
console.log(str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment