Created
July 27, 2015 11:48
-
-
Save joewalker/8f0a929bef16aea32047 to your computer and use it in GitHub Desktop.
What happens if you nest toJSON functions?
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
var obj = { | |
foo: 'foo', | |
toJSON: function() { | |
return { | |
bar: 'bar', | |
toJSON: function() { | |
return { | |
baz: 'baz' | |
}; | |
} | |
}; | |
} | |
}; | |
JSON.stringify(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spoiler:
{"bar":"bar"}