Shallow clone objects and arrays, or return primitive values directly.
Install
Install with npm:
npm i clone-shallow --save-dev
Usage
;
value
{*} The value to clone.return
{*} The cloned value.
Example
Arrays:
var a = 'a' 'b' 'c';var b = ;a = a; console;//=> a: [ 'a', 'b', 'c', 'new' ] console;//=> b: [ 'a', 'b', 'c' ]
Objects:
var extend = ;var a = foo: 'alpha' bar: 'beta' baz: 'gamma';var b = ;a = ; console;//=> a: { foo: 'alpha', bar: 'beta', baz: 'gamma', quux: 'delta' }console;//=> b: { foo: 'alpha', bar: 'beta', baz: 'gamma' }
Also see:
- clone-array if you just need to clone arrays.
- clone-object if you just need to clone objects.
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on June 30, 2014.