Created
October 1, 2010 08:39
-
-
Save think49/605932 to your computer and use it in GitHub Desktop.
dumpObject.js : オブジェクトを整形文字列にして返します。
This file contains hidden or 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
// dumpObject.js | |
// オブジェクトを整形文字列にして返します | |
function dumpObject (obj) { | |
var p, result; | |
result = []; | |
for (p in obj) { | |
if (obj.hasOwnProperty(p)) { | |
result.push(' ' + p + ': "' + obj[p] + '"'); | |
} | |
} | |
return '{\n' + result.join(',\n') + '\n}\n'; | |
} | |
alert(dumpObject({a:'value a', b:'value b', c:'value c'})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment