Skip to content

Instantly share code, notes, and snippets.

@jhs
Created January 4, 2012 05:42
Show Gist options
  • Save jhs/1558673 to your computer and use it in GitHub Desktop.
Save jhs/1558673 to your computer and use it in GitHub Desktop.
Back to basics
// Old and busted.
Object.keys(obj).forEach(function (k, _, __) {
var val = obj[k]
if (val && typeof val === "object") {
children.push(k)
} else {
out += safe(k) + " = " + safe(val) + "\n"
}
})
// New hotness.
Object.keys(obj).forEach(function (k, _, __) {
var val = obj[k]
if (val && typeof val === "object")
children.push(k)
else
out += safe(k) + " = " + safe(val) + "\n"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment