Skip to content

Instantly share code, notes, and snippets.

@discretepackets
Last active December 18, 2015 11:38
Show Gist options
  • Save discretepackets/5776731 to your computer and use it in GitHub Desktop.
Save discretepackets/5776731 to your computer and use it in GitHub Desktop.
var _ = require('underscore');
var obj = {
one_level_string: "1",
one_level_array: ["hey", "there"],
two_levels: {
a: "a",
b: "b",
c: ["ccc", "ddd"],
d: {
hi: "hi",
no_item: null
},
e: [{ ha: "yay" }]
}
}
function recursive_check(input) {
if (!input) return;
if (_.isArray(input)) {
for (var i = 0; i < input.length; i++) {
recursive_check(input[i]);
}
} else if (_.isObject(input)) {
for (key in input) {
recursive_check(input[key]);
}
} else if (typeof input == 'string') {
console.log(">", input, "\n");
} else {
return;
}
}
recursive_check(obj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment