The object to copy
If true, handles circular references and complex objects for safe JSON serialization.
When enabled, circular references are replaced with '[Circular Reference]',
complex objects without toJSON() are replaced with their type names,
Error objects are specially handled to extract name/message/stack,
and Dates are converted to ISO strings. Default: false
Maximum recursion depth when resolveCircularReferences is true (default: 10)
A new object with scalars and arrays copied
This utility function will copy all scalar and array properties from an object to a new object and return the new object. This function will NOT copy non-plain object instances (unless they implement
toJSON()orresolveCircularReferencesis true).The function respects the standard JavaScript
toJSON()protocol: if a value exposes atoJSON()method (asDate,BaseInfosubclasses, and user-defined classes can), the method is invoked and its return value is processed in place of the original. This mirrors howJSON.stringify()handles serialization.Arrays are recursively processed — each item is copied/toJSON'd individually — so nested objects with
toJSON()are unwrapped to their serializable form.