clone-object
Create a shallow clone of an object.
Last updated 12 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install clone-object 
SYNC missed versions from official npm registry.

clone-object NPM version

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.

Current Tags

  • 0.1.0                                ...           latest (12 years ago)

1 Versions

  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |