3 ms·
Right, JSON.stringify(Object('hi')) does that, but just plain Object('hi') without wrapping in stringify returns { '0': 'h', '1': 'i' } Is it part of
by firefoxman1 15y ago
Right,
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.