3 ms·
> No indexed properties on objects: The fast path is optimized for objects with regular, string-based keys. If an object contains array-like indexed properties
by notpushkin 1y ago
> No indexed properties on objects: The fast path is optimized for objects with regular, string-based keys. If an object contains array-like indexed properties (e.g., '0', '1', ...), it will be handled by the slower, more general serializer.
Any idea why?
- Timwi 1y agoI wonder that too. Are they saying that objects with integer-looking keys are serialized as JSON arrays?? Surely not...?
- inbx0 1y agoMy guess would be because they affect property ordering, complicating the stringification. The default object property iteration rules in JS define that numeric properties are traversed first in their numeric order, and only then others in the order they were added to the object. Since the numbers need to be in their numeric, not lexical, order, the engine would also need to parse them to ints before sorting. > JSON.stringify({b: null, 10: null, 1: null, a: null}) '{"1":null,"10":null,"b":null,"a":null}'