clone-object
v0.1.0
Published
Create a shallow clone of an object.
Downloads
1,717
Maintainers
Readme
clone-object
Create a shallow clone of an object.
Install
Install with npm:
npm i clone-object --save-dev
Usage
clone(obj);
Shallow clone an object.
obj
{Object}obj
The object to clone.return
{Object} The new object.
Example
var extend = require('xtend');
var a = {foo: 'alpha', bar: 'beta', baz: 'gamma'};
var b = cloneObject(a);
a = extend(a, {quux: 'delta'});
console.log('a:', a);
//=> a: { foo: 'alpha', bar: 'beta', baz: 'gamma', quux: 'delta' }
console.log('b:', b);
//=> b: { foo: 'alpha', bar: 'beta', baz: 'gamma' }
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.