Skip to content

Instantly share code, notes, and snippets.

@hwindo
Created August 18, 2016 07:48
Show Gist options
  • Save hwindo/b64dd8fa827032db8c23de600ca2bc88 to your computer and use it in GitHub Desktop.
Save hwindo/b64dd8fa827032db8c23de600ca2bc88 to your computer and use it in GitHub Desktop.
Logging any item
function logStuff(stuff) {
if (typeof stuff === "string") {
console.log("type: String");
console.log(stuff);
} else if (typeof stuff === "object") {
console.log("type: Object");
for (var index in stuff) {
console.log(index + ": " + stuff[index]);
}
} else if (typeof stuff === "array") {
console.log("type: Array");
for (var x = 0, z = stuff.length; x < z; x++) {
console.log("item " + i + ": " + stuff[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment