Serializes objects for string-safe stashing in WebStorage, Cache, etc. Uses JSON.stringify where available, else returns a stringified single key:value object (e.g., { "$BigInt": "123" }) for custom types.
JSON.stringify
{ "$BigInt": "123" }
The object to stringify
The safely stringified representation
stringify(123n); // '{"$BigInt":"123"}' Copy
stringify(123n); // '{"$BigInt":"123"}'
Serializes objects for string-safe stashing in WebStorage, Cache, etc. Uses
JSON.stringifywhere available, else returns a stringified single key:value object (e.g.,{ "$BigInt": "123" }) for custom types.