4.17.11
3.10.1
2.4.2
1.3.1
_.clone(value)
Creates a shallow clone of value
.
Note: This method is loosely based on the
structured clone algorithm
and supports cloning arrays, array buffers, booleans, date objects, maps,
numbers, Object
objects, regexes, sets, strings, symbols, and typed
arrays. The own enumerable properties of arguments
objects are cloned
as plain objects. An empty object is returned for uncloneable values such
as error objects, functions, DOM nodes, and WeakMaps.
Since
0.1.0
Arguments
argument
value
type
*
description
The value to clone.
Returns
(array)
Example
var objects = [{ a: 1 }, { b: 2 }];
var shallow = _.clone(objects);
console.log(shallow[0] === objects[0]);
// => true
var objects = [{ a: 1 }, { b: 2 }];
var shallow = _.clone(objects);
console.log(shallow[0] === objects[0]);
// => true