3 ms·
Make sure you're not on a page with external scripts that could be mucking it up. If you're recent modern browser `JSON.stringify(Object('hi'))` should produce
by jdd 15y ago
Make sure you're not on a page with external scripts that could be mucking it up.
If you're recent modern browser `JSON.stringify(Object('hi'))` should produce '"hi"'.
See http://cl.ly/2J3B0e1z1o3e0T3x2b0l http://cl.ly/2J3B0e1z1o3e0T3x2b0l.
- firefoxman1 15y agoRight, JSON.stringify(Object('hi')) does that, but just plain Object('hi') without wrapping in stringify returns { '0': 'h', '1': 'i' } Is it part of the JSON spec that you first call .toString() on array-like objects?
- jdd 15y ago`Object('hi')` produces the equivalent of `new String('hi')`. The stringify behavior is spec'ed here http://es5.github.com/#x15.12.3 http://es5.github.com/#x15.12.3 [Step 4b of the abstract operation Str(key, holder) algorithm]. See http://cl.ly/2E1l2X3X3U1B2N1d3G1k http://cl.ly/2E1l2X3X3U1B2N1d3G1k.
- firefoxman1 15y agoAhh that makes sense. I appreciate your research finding that part in the spec.