1 var baseClone = require('./_baseClone');
3 /** Used to compose bitmasks for cloning. */
4 var CLONE_SYMBOLS_FLAG = 4;
7 * Creates a shallow clone of `value`.
9 * **Note:** This method is loosely based on the
10 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
11 * and supports cloning arrays, array buffers, booleans, date objects, maps,
12 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
13 * arrays. The own enumerable properties of `arguments` objects are cloned
14 * as plain objects. An empty object is returned for uncloneable values such
15 * as error objects, functions, DOM nodes, and WeakMaps.
21 * @param {*} value The value to clone.
22 * @returns {*} Returns the cloned value.
26 * var objects = [{ 'a': 1 }, { 'b': 2 }];
28 * var shallow = _.clone(objects);
29 * console.log(shallow[0] === objects[0]);
32 function clone(value) {
33 return baseClone(value, CLONE_SYMBOLS_FLAG);
36 module.exports = clone;