Creates a shallow clone of an object or array.
For primitive values, returns the value as-is. For objects and arrays, creates a new instance with the same properties or elements.
The type of the object to clone.
The object to clone.
A shallow clone of the object.
import { clone } from './AcCmLodashUtils'const original = { a: 1, b: 2 }const cloned = clone(original)cloned.a = 3console.log(original.a) // 1 (unchanged)console.log(cloned.a) // 3const arr = [1, 2, 3]const clonedArr = clone(arr) // [1, 2, 3] Copy
import { clone } from './AcCmLodashUtils'const original = { a: 1, b: 2 }const cloned = clone(original)cloned.a = 3console.log(original.a) // 1 (unchanged)console.log(cloned.a) // 3const arr = [1, 2, 3]const clonedArr = clone(arr) // [1, 2, 3]
Creates a shallow clone of an object or array.
For primitive values, returns the value as-is. For objects and arrays, creates a new instance with the same properties or elements.