A simple JSON stringify function which requires Array.prototype.map method.
The following users provided lots of ideas and improvements of the code.
@Kambfhase, @hartrock, @atk, @haochi, @jed
Actually, I just provided a deficient version at first. The other versions were created by these users(especially @atk). You may see the discussion below.
A very interesting feat is the intentional defective object detection in this case. A string containing "t]" will falsely be identified as object and starts the iteration. The iterated characters "t" and "]" will not restart the iteration themselves, therefore unwanted recursion will not happen and the function may be a bit slower, but works without failure nevertheless.
I'd like to see some more informations in the annotated version about this.
Update: thank you!