Created
January 4, 2012 05:42
-
-
Save jhs/1558673 to your computer and use it in GitHub Desktop.
Back to basics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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