clone es-toolkit
Creates a shallow copy of the given value.
Usage
clone(obj)
Use clone when you want to create a shallow copy of objects, arrays, Dates, RegExps, and other values. A shallow copy means only the top-level properties are copied, and nested objects or arrays share references with the original.
It supports various JavaScript types like Date, RegExp, Map, and Set.
Parameters
objTrequired
The value to clone. It can be any type, such as objects, arrays, or primitive values.
Returns
A shallow copy of the given value.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.